ballerina-distribution
ballerina-distribution copied to clipboard
Logging configurations mess up in the presence of multiple bindings for SLF4J
When there are multiple bindings available for SLF4J in the class path, it messes with the logging configuration. According to SLF4J [1], the way a binding is selected is dependent on the JVM and therefore, should be considered a random selection. This issue may be possible to solve with SLF4J 1.8. But currently, it is still in alpha stage.
This will be an issue if a user puts a 3rd party library which has a logging framework embedded in it to the <BALLERINA_HOME>/bre/lib
directory.
To further illustrate this issue, the following is a normal log output to the console from a simple Ballerina main program.
2017-06-30 17:00:58,658 INFO [com.xyz] - Inside package 'com.xyz'
2017-06-30 17:00:58,663 INFO [com.abc] - Inside package 'com.abc'
2017-06-30 17:00:58,664 ERROR [com.abc] - Error inside package 'com.abc'
Given below is the result of executing the same program, but this time, a library with Log4J embedded in it (activemq-all-5.14.0.jar
) was placed in <BALLERINA_HOME>/bre/lib
directory.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/pubudu/products/ballerina-tools-0.89/bre/lib/activemq-all-5.14.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/pubudu/products/ballerina-tools-0.89/bre/lib/slf4j-jdk14-1.7.22.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]
INFO | Inside package 'com.xyz'
INFO | Inside package 'com.abc'
ERROR | Error inside package 'com.abc'
As it can be seen from the last 3 lines, the log format is not the format we specified.
SLF4J dependency is removed in https://github.com/ballerina-platform/module-ballerina-log/pull/116.
I don't think removing it from just the log module would fix this issue. But removing the dependency on a log library would indeed fix the user log format messing up issue. This is not an std lib issue, rather a general issue in the distribution.
@pubudu91 Ack. Transferred the issue to ballerina-distribution.