send tensorflow log messages to log file

5,138 views
Skip to first unread message

brian...@gmail.com

unread,
Jan 29, 2016, 12:17:20 PM1/29/16
to Discuss
Does anyone know how to send the standard tensorflow log mesages to a file (in addition to stdout)? I have my own logging, with a file handler, and I want to add the tensorflow output to the same file.

By log messages I mean stuff like this:
I tensorflow/core/common_runtime/gpu/pool_allocator.cc:244] PoolAllocator: After 14504 get requests, put_count=15013 evicted_count=5000 eviction_rate=0.333045 and unsatisfied allocation rate=0.332322

I tried getting python's root logger and adding a file handler, but it looks like these messages are not going through the standard python logging channels.

Thanks!

josh11b

unread,
Feb 1, 2016, 4:40:08 PM2/1/16
to Discuss, brian...@gmail.com
TensorFlow uses this for logging in Python:


but the message you are referencing comes from the C++ side of things, which is defined here:


In particular it looks like logging messages are written to stderr in this line:


and there do not appear to be any facilities at present for redirecting that output to anyplace else.

Josh

Martin Wicke

unread,
Feb 1, 2016, 4:43:08 PM2/1/16
to josh11b, Discuss, brian...@gmail.com
Redirecting stderr to stdout and then passing it through `tee` should do the trick.

--
You received this message because you are subscribed to the Google Groups "Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss+u...@tensorflow.org.
To post to this group, send email to dis...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/discuss/0f66b5f5-2540-41f7-be7d-9b2a0b0c5cd0%40tensorflow.org.

brian...@gmail.com

unread,
Feb 1, 2016, 7:59:58 PM2/1/16
to Discuss, brian...@gmail.com
Ah, thanks. I had found _logging.py but not the C++ files. Makes sense that I can't get to them from Python's logging handler now.

st553

unread,
Feb 27, 2016, 12:16:06 PM2/27/16
to Discuss, brian...@gmail.com
Is it possible to redirect the C++ stderr messages in a way that I could use a standard python logging framework?

Nicholas Dufour

unread,
Apr 23, 2016, 5:37:42 PM4/23/16
to Discuss
Thanks for that info Josh. Do you by any chance have any idea how to add a timestamp to the tensorflow logging messages in c++?

i.e., 

LOG(INFO) << "Waiting for models to be loaded...";

To something like

time_t ltime;
ltime
=time(NULL);
LOG
(INFO) << asctime( localtime(&ltime) ) << "Waiting for models to be loaded...";

(I'm not sure if this syntax works, I'm super rusty as C++)
Message has been deleted

Mohammed AlQuraishi

unread,
May 25, 2017, 11:11:38 AM5/25/17
to Discuss, brian...@gmail.com
With regards to the original question of logging stderr to a file from within Python, the approach described here (for the C-level) output works for me with TensorFlow:

Reply all
Reply to author
Forward
0 new messages