# Any way to log message() outputs to a log file?

**URL:** <https://discourse.cmake.org/t/any-way-to-log-message-outputs-to-a-log-file/2021>\
**Category:** Code\
**Created:** [October 17, 2020, 8:54pm UTC](https://discourse.cmake.org/t/any-way-to-log-message-outputs-to-a-log-file/2021 "2020-10-17T20:54:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![starseeker](https://discourse.cmake.org/user_avatar/discourse.cmake.org/starseeker/32/4923_2.png) [@starseeker](https://discourse.cmake.org/u/starseeker)\
**Post date:** [October 17, 2020, 8:54pm UTC](https://discourse.cmake.org/t/any-way-to-log-message-outputs-to-a-log-file/2021/1 "2020-10-17T20:54:30Z")

</div>

Some years ago, there was some discussion about introducing a way in CMake to specify a file to use to log a copy of the message() function’s outputs:

[https://cmake.org/pipermail/cmake-developers/2015-July/025681.html](https://cmake.org/pipermail/cmake-developers/2015-July/025681.html)

Does anyone know if a way to log message() outputs to a file was ever introduced? I’m not seeing anything from the message() documentation online…

Thanks,  
CY

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [October 17, 2020, 9:16pm UTC](https://discourse.cmake.org/t/any-way-to-log-message-outputs-to-a-log-file/2021/2 "2020-10-17T21:16:49Z")

</div>

I’m not aware of any such capability having been developed since then. If you are on a Unix-based platform though, you should be able to use `tee` and pipe your output through that to get a similar end result. It would have the added benefit of also capturing output from any `external_process()` call too, not just `message()` commands.

---

<div class="post-metadata">

**Author:** ![starseeker](https://discourse.cmake.org/user_avatar/discourse.cmake.org/starseeker/32/4923_2.png) [@starseeker](https://discourse.cmake.org/u/starseeker)\
**Post date:** [October 18, 2020, 2:50am UTC](https://discourse.cmake.org/t/any-way-to-log-message-outputs-to-a-log-file/2021/3 "2020-10-18T02:50:57Z")

</div>

It’s a good thought - thanks for that - but unfortunately the design goal is to capture all output from the CMake configure process in a log file automatically (i.e. without users having to do anything special) across all platforms so we can’t depend on Unix specific tools.

(Our message() wrapper does the job now, so we do have a solution, but it’s using the discouraged wrap-the-existing-function trick…)

Thanks,  
CY

---

<div class="post-metadata">

**Author:** ![tom](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/3d9bf3/32.png) [@tom](https://discourse.cmake.org/u/tom)\
**Post date:** [October 27, 2020, 12:02pm UTC](https://discourse.cmake.org/t/any-way-to-log-message-outputs-to-a-log-file/2021/4 "2020-10-27T12:02:14Z")

</div>

I use a similar work-around, and would also appreciate a more fully-featured message(). For now, the work-around does appear to be quite robust.
