pythontensorflowloggingprefixverbosity

How to remove the prefix printed out by tf.logging.info


Printing log lines in TensorFlow is done with functions in tf.logging like tf.logging.info, tf.logging.log, etc.

import tensorflow as tf;

tf.logging.set_verbosity(tf.logging.INFO);
tf.logging.info(tf.__version__);

However, when printing on Google Colab, there's a real long prefix before the printed value:

I0903 10:16:46.097078 140433498875776 <ipython-input-9-a435f70e3dca>:22] 1.14.0

How to change tf.logging to omit that prefix? It's long and unnecessary. And even when running the code directly with python3 in terminal, there's still a shorter prefix (the version is 1.12.0 in terminal):

INFO:tensorflow: 1.12.0

And I want to remove this short prefix too.


Solution

  • I finally found the answer that it is impossible to remove the prefix by tf.logging.* functions. It is a done in the C/C++ level of the library and no way to remove it.

    It is stated in there: https://github.com/tensorflow/tensorflow/issues/12537