Sun mostly sticks with java.util.logging (jul) in their products. jul is fairly unflexible but we need to live with it. However I usually would use log4j with slf4j as logging facade. In order to get more control over jul logging output you can use the slf4j to java.util.logging bridge. Here I show how to set it up with Spring and Maven

1
<bean class="org.slf4j.bridge.SLF4JBridgeHandler" init-method="install" scope="singleton"/>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jul-to-slf4j</artifactId>
      <version>1.5.4</version>
  </dependency>
  <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>1.5.4</version>
  </dependency>
  <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.15</version>
      <exclusions>
          <exclusion>
              <groupId>com.sun.jmx</groupId>
              <artifactId>jmxri</artifactId>
          </exclusion>
          <exclusion>
              <groupId>com.sun.jdmk</groupId>
              <artifactId>jmxtools</artifactId>
          </exclusion>
      </exclusions>
  </dependency>

Comments