Solvedabseil py abseil interferes with python logging

I have a script where I'm importing a module that internally uses abseil logging. The rest of our code base is using standard python logging. This is leading to a situation where importing that module is interfering with the rest of the code base using standard logging and causing lost log messages.

See here for a description of the issue: tensorflow/hub#263

Have others run into this issue before?

20 Answers

✔️Accepted Answer

Other Answers:

Version 0.8.0 is released on PyPI, absl.logging no longer registers itself at import time.

Relevant commits: 05c000a and d162b02

@gpshead have you now given any thought to this issue that you called "obvious in hindsight"?

As more and more Google-released libraries switched from not-abseil to abseil, this mucking with global state, removing existing logging handlers, overriding formats, etc. is getting really costly.

For my team, it's Capirca that's biting us. See also #102.

(cc: @tituswinters, if he's still leading Abseil)

We have a fix and should be pushed out in a week or two.

@gpshead Thanks for the quick reply!

I tried the second workaround and that helped. For anyone else that has a similar situation, I also had to set the verbosity level:

# Work around TensorFlow's absl.logging depencency which alters the
# default Python logging output behavior when present.
import sys
if 'absl.logging' in sys.modules:
  import absl.logging
  absl.logging.set_verbosity('info')
  absl.logging.set_stderrthreshold('info')
  # and any other apis you want, if you want

+1 to your suggestion. I agree it would be nice to support use in libraries that may be used in code bases with existing logging mechanisms in place.

More Issues: