Skip to content

restlet logging using log4j #706

Open
@ddanny

Description

@ddanny

I was a happy user of restlet 2.0.15 until yesterday, when they discontinued the 2.0.x versions from their Maven repository, so I had to upgrade to 2.1.1.

In the old version I was using SLF4J as a bridge to Log4J and I was able to get the restlet logs to my Log4J based logging system. This is no longer working with restlet 2.1.1. Any ideas what I would need to fix?

This is the way it was working:

public static void initLogging() {
  // install the SL4J bridge such as the org.restlet logging messages to
  // be appended to Log4J too, from the default java.util.logging based
  // implementation
  SLF4JBridgeHandler.install();
  ...
  if (log4j != null) {
      DOMConfigurator.configure(log4j);
  }
  log = Logger.getLogger(SomeClass.class);
}

Below is a list of the restlet and slf4j related dependencies I have in my pom.xml:

    <dependency>
        <groupId>org.restlet.jse</groupId>
        <artifactId>org.restlet</artifactId>
        <version>2.1.1</version>
    </dependency>

    <dependency>
        <groupId>org.restlet.jse</groupId>
        <artifactId>org.restlet.ext.crypto</artifactId>
        <version>2.1.1</version>
    </dependency>

    <dependency>
        <groupId>org.restlet.jse</groupId>
        <artifactId>org.restlet.ext.json</artifactId>
        <version>2.1.1</version>
    </dependency>

    <dependency>
        <groupId>org.restlet.jse</groupId>
        <artifactId>org.restlet.ext.simple</artifactId>
        <version>2.1.1</version>
    </dependency>

    <dependency>
        <groupId>org.restlet.jse</groupId>
        <artifactId>org.restlet.ext.ssl</artifactId>
        <version>2.1.1</version>
    </dependency>

    <dependency>
        <groupId>org.restlet.jse</groupId>
        <artifactId>org.restlet.ext.slf4j</artifactId>
        <version>2.1.1</version>
    </dependency>

    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
    </dependency>

    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.2</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.2</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jul-to-slf4j</artifactId>
        <version>1.7.2</version>
    </dependency>

Once again, this was all working with restlet version 2.0.15, slf4j 1.6.4 and without any org.restlet.ext.slf4j dependency.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions