-
Feature Request
-
Resolution: Done
-
Major
-
jBPM 6.0.0.Final
-
None
Currently there are many different logging framework in use (java.util.logging, slf4j, log4j, system outs, etc). There is a major need to align them to use same approach all over the code base. Here are the main rules to be applied:
1) In your java code, use the slf4 interfaces:
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Sfl4j is just a very-efficiently logging interface, it doesn't actually log itself.
Make sure you understand that
logger.trace("Hello {}", username);
is a LOT faster than
logger.trace("Hello " + username);
if trace is disabled (which it usually is).
2) Add maven dependencies on slf4j-api and logback-classic:
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope> <!--or <scope>runtime</scope> for examples and wars -->
</dependency>
Remove/exclude any log4j and slf4j-log4j dependencies.
Note: log4j hasn't seen a release in 5 years. It's dead (and very slow).
3) Add a logback-test.xml file directly under in src/test/resources:
For example:
https://github.com/droolsjbpm/optaplanner/blob/master/optaplanner-examples/src/test/resources/logback-test.xml
4) For end-user jars (so examples and wars, but NOT jbpm-flow etc), add a logback.xml directly under src/main/resources:
For example:
https://github.com/droolsjbpm/optaplanner/blob/master/optaplanner-examples/src/main/resources/logback.xml
Note: If both logback-test.xml and logback.xml are on the classpath, logback will ignore the latter and only use logback-test.xml.
So never put logback-test.xml in a non-test classpath.
- is related to
-
JBPM-3223 Clean up system outs in jBPM5 codebase
- Resolved