cmmnbuild-dep-manager log handler
Typically it should be an (end) application which defines the logging implementation of an environment. Unfortunately, for pure Python applications which have a (possibly transitive) dependency on cmmnbuild-dep-manager
based Java environments it isn't practical for each application to define the Java logging implementation. It is clear that the respective libraries using cmmnbuild-dep-manager
must not mandate a logging solution, as these things can collide. For example, today's pjlsa
, pyjapc
and pytimber
each specify a logging implementation, and there is no guarantee they are the same one (in fact, they aren't the same one). In this situation, you end up with a warning such as:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/tmp/deploy-tmp/acc-py-rich-environment/0.1.dev11+g0720bee.d20210316/venv/lib/python3.7/site-packages/cmmnbuild_dep_manager/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/tmp/deploy-tmp/acc-py-rich-environment/0.1.dev11+g0720bee.d20210316/venv/lib/python3.7/site-packages/cmmnbuild_dep_manager/lib/log4j-slf4j-impl-2.12.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
I propose that instead of pushing the logging implementation onto the end applications, we treat cmmnbuild-dep-manager
as the canonical place where logging can be controlled. Libraries MUST not define their own logging implementations. (It is plausible that this could be switched at runtime without having to re-resolve all of the JARs, but that is out of scope for this issue)
With this in place, I believe we could have Java logging handled by Python logging handlers, and would be able to control things such as log level and log destination conveniently at the application level.
The key messages here:
- Libraries MUST not declare logging implementations
- cmmnbuild-dep-manager MUST exclusively declare a logging implementation
- cmmnbuild-dep-manager MAY choose to publish Java logs through standard python logging