change to root logger affects other projects
Describe the bug Open3D append to the Python root logger which in return yields doubled log messages when setting a logging handler in another project.
To Reproduce Steps to reproduce the behavior:
import logging
print(logging.getLogger().handlers) # > []
import opend3d
print(logging.getLogger().handlers) # > [<StreamHandler stderr (NOTSET)>]
Expected behavior
Open3D should use logging.getLogger(__name__) and only change the open3D logger and not others.
This should give
print(logging.getLogger(__name__).handlers) # > [<StreamHandler stderr (NOTSET)>]
where __name__ == "open3d"
~~This seems to be fixed in 0.13.0+e571ba9~~
This is still an issue in 0.14.1
>>> import logging; print(logging.getLogger().handlers)
[]
>>> import open3d; open3d.__version__
'0.14.1'
>>> print(logging.getLogger().handlers)
[<StreamHandler <stderr> (NOTSET)>]
Still an issue in 0.15.2:
import logging
print(logging.getLogger().handlers) # > []
import opend3d
print(logging.getLogger().handlers) # > [<StreamHandler stderr (NOTSET)>]
When can this problem be solved? I have the same problem.
Breaking our logging system too. This is somewhat critical for us. Would you accept a pull request? For now, fixing locally with:
import open3d
# required because open3d changes default logging behavior (https://github.com/isl-org/Open3D/issues/4228)
logging.getLogger().handlers.clear()
I've just encountered the same issue. While it can be resolved with a logging.root.handlers.clear(), it does raise questions. I'm curious whether this is considered bad practice on the side of Open3D. It's surprising that this could have been overlooked.