Bug 995133 - jBPM should use 1 logging system (and standarize on slf4j with logback)
Summary: jBPM should use 1 logging system (and standarize on slf4j with logback)
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss BPMS Platform 6
Classification: Retired
Component: Build and Assembly
Version: 6.0.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ER4
: 6.0.0
Assignee: Geoffrey De Smet
QA Contact: Ivo Bek
URL:
Whiteboard:
Depends On:
Blocks: 989519
TreeView+ depends on / blocked
 
Reported: 2013-08-08 15:27 UTC by Geoffrey De Smet
Modified: 2014-08-06 20:12 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-08-06 20:12:32 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Geoffrey De Smet 2013-08-08 15:27:18 UTC
Most modules use slf4j-logback. These don't and need to switch to that too:

jbpm-form-modeler-renderer: commons-logging (compile time even!)
jbpm-designer-backend: slf4j-jdk14 (compile time even!)
jbpm-designer-client: slf4j-jdk14 (compile time even!)
- Note: Many modules that depends on designer exclude logging dependencies because of this
jbpm-distribution: slf4j-log4j12
jbpm-examples: slf4j-log4j12
jbpm-executor: slf4j-log4j12
jbpm-test: slf4j-log4j12
droolsjbpm-bpms-distribution: slf4j-log4j12



HOW TO USE SLF4J AND LOGBACK PROPERLY
=====================================

Use slf4j with logback

Here's how it works:

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 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-text.xml and logback.xml are on the classpath, logback will ignore the latter and only use logback-text.xml.
So never put logback-text.xml in a non-test classpath.

5) For more info:
http://www.slf4j.org/manual.html (how to use from code)
http://logback.qos.ch/documentation.html (how to configure it to do what you want it do)

Comment 2 Geoffrey De Smet 2013-08-08 15:30:39 UTC
Blocks https://bugzilla.redhat.com/show_bug.cgi?id=994981

Comment 3 Maciej Swiderski 2013-08-12 14:35:20 UTC
cleaned up jbpm-executor, jbpm-test and jbpm-examples, pushed both to master and 6.0.x branch:
https://github.com/droolsjbpm/jbpm/commit/82bb74193cd8cac40684257b9cfe8ac175d48fc2

Comment 4 Geoffrey De Smet 2013-08-13 15:08:07 UTC
Maciesj has fixed jbpm-executor, jbpm-examples, jbpm-test.
gdesmet has fixed jbpm-distribution

sr_pere is fixing on form-modeler
tihimor is fixing on designer

Comment 5 Geoffrey De Smet 2013-08-16 11:26:42 UTC
pere and tiho have fixed form-modeler and designer too. All fixed now.

Comment 9 Ivo Bek 2013-11-18 13:35:28 UTC
Verified.
It's not mentioned but Geoffrey has removed slf4j-log4j12 from droolsjbpm-bpms-distribution https://github.com/droolsjbpm/droolsjbpm-integration/commit/aaeaa8a90e658e0eeda7ae07cdda796a7d6485ab


Note You need to log in before you can comment on or make changes to this bug.