Skip to content

Logging

mattweber edited this page Aug 30, 2012 · 3 revisions

Cloud9 Logging

Cloud9 logging uses slf4j and logback.

Configuration

etc/logback.xml

This is the main logging configuration file. This is the configuration that will be included when we package builds. Do not change this file during development unless it is for changes you want included in release builds.

etc/logback-test.xml

This is the configuration file you can use during development and running tests. It is not tracked by revision control so each developer can maintain their own personal logging settings. Make a copy of logback.xml as a starting point. If this file exists when performing a release build, it will not be included.

src/test/resources/logback-test.xml

If this file exists, it will be used only while running tests. It takes precedence over the configuration files mentioned above.

etc/logback-access.xml

This is the configuration file for access logs.

Exclude Other Logging Framework

When adding new dependencies make sure they do not pull logging frameworks other than slf4j and logback. Use mvn dependency:tree and mvn -Pstandalone dependency:tree to check which dependencies are being pulled in. The most likely scenario is that log4j or commons-logging will be pulled in. If this is the case, you can add one of the following to the exclusions of the dependency:

<exclusion>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
</exclusion>

or

<exclusion>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
</exclusion>

Here is an example where we exclude commons-logging from our spring-context dependency:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>${org.springframework-version}</version>
    <exclusions>
        <!-- Exclude Commons Logging in favor of SLF4j -->
        <exclusion>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
         </exclusion>
    </exclusions>
</dependency>