How to use third-party log4j appenders in Nuxeo Tomcat distribution?

EDIT: At Julien Carsique's request I'll explain what I did to get Sentry logging working. We use Puppet for creating configuration files rather than Nuxeo templates, but the edits are so straightforward that it doesn't matter how it's done.

  1. Deploy a Sentry server and acquire the DSN for your Nuxeo system to access it.
  2. Download the raven-java jars and dependencies. I simply made a dummy Maven project and relied on dependency:copy-dependencies to acquire them. The jars should include raven-x.0.jar, raven-log4j-x.0.jar, jackson-core-2.2.0.jar, commons-codec-1.8.jar, slf4j-api-1.7.5.jar, and slf4j-log4j12-1.7.5.jar. You must match the Raven version (3.0 or 4.0) with the protocol used by your Sentry server.
  3. Copy these jars into NUXEO_HOME/server/lib (the Tomcat lib directory).
  4. Add code like the following to log4j.xml, which should be in the same directory:
<appender name="SENTRY" class="net.kencochrane.raven.log4j.SentryAppender">
  <param name="dsn" value="https://this-is-your-sentry-dsn-value-paste-it-in-exactly:1234/3"/>
  <filter class="org.apache.log4j.varia.LevelRangeFilter">
    <param name="levelMin" value="WARN"/>
   <level value="WARN" />
   <appender-ref ref="CONSOLE" />
   <appender-ref ref="FILE" />
   <appender-ref ref="SENTRY" />

My trouble below was caused by an invalid DSN – it didn't even resolve in DNS.

ORIGINAL QUESTION (fixed it myself):

I would like to use the raven-java Log4J appender to log notable events to a Sentry event console. I tried the simplest thing which could possibly work, which is to deploy the raven jars and their dependencies into Nuxeo's server/lib directory, and edit the log4j.xml to add a new appender. I receive the following error on startup:

2013-06-12 20:37:41,062 ERROR [org.nuxeo.runtime.tomcat.NuxeoLauncher] Failed to handle event
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
        at java.lang.reflect.Method.invoke(
        at org.nuxeo.osgi.application.FrameworkBootstrap.start(
        at org.nuxeo.runtime.tomcat.NuxeoLauncher.handleEvent(
        at org.nuxeo.runtime.tomcat.NuxeoLauncher.lifecycleEvent(
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
        at org.apache.catalina.core.StandardContext.start(
        at org.apache.catalina.core.ContainerBase.addChildInternal(
        at org.apache.catalina.core.ContainerBase.addChild(
        at org.apache.catalina.core.StandardHost.addChild(
        at org.apache.catalina.startup.HostConfig.deployDescriptor(
        at org.apache.catalina.startup.HostConfig.deployDescriptors(
        at org.apache.catalina.startup.HostConfig.deployApps(
        at org.apache.catalina.startup.HostConfig.start(
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
        at org.apache.catalina.core.ContainerBase.start(
        at org.apache.catalina.core.StandardHost.start(
        at org.apache.catalina.core.ContainerBase.start(
        at org.apache.catalina.core.StandardEngine.start(
        at org.apache.catalina.core.StandardService.start(
        at org.apache.catalina.core.StandardServer.start(
        at org.apache.catalina.startup.Catalina.start(
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
        at java.lang.reflect.Method.invoke(
        at org.apache.catalina.startup.Bootstrap.start(
        at org.apache.catalina.startup.Bootstrap.main(
Caused by: java.lang.NullPointerException
        at net.kencochrane.raven.log4j.SentryAppender.buildEvent(
        at net.kencochrane.raven.log4j.SentryAppender.append(
        at org.apache.log4j.AppenderSkeleton.doAppend(
        at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(
        at org.apache.log4j.Category.callAppenders(
        at org.apache.log4j.Category.forcedLog(
        at org.apache.log4j.Category.log(
        at org.nuxeo.osgi.application.loader.FrameworkLoader.printStartMessage(
        at org.nuxeo.osgi.application.loader.FrameworkLoader.doStart(
        at org.nuxeo.osgi.application.loader.FrameworkLoader.start(
        ... 31 more

This error is interesting because it seems to indicate that the new classes and configurations are available, but that something in the way Nuxeo starts within Tomcat makes the state of the Raven logging system invalid.

Is there something general I am missing about using third-party log4j appenders with Nuxeo/Tomcat, or is this problem specific to Raven?

1 votes

1 answers



In order to answer my own question, this was caused by incorrect configuration of the Raven appender. This error apparently occurred before the appender of server.log was initialized. I wonder how to detect this class of error in general, since there was no indication of anything wrong in any of the Nuxeo-documented logs.

0 votes

You mean there were unlogged errors? Maybe starting the server in console would show them? Did you look into the other log files?

Would you mind contribute or document a Raven Log4J configuration template? Regards.

I looked in all the log files and didn't see anything. I assume that the error message complains about a bad initialization value in log4j.xml for the Sentry appender.

Right now I'm not deploying from source but rather from the APT package. I can write up what I'm doing with that installation, though.


Strange you don't get an error, I'll try to reproduce it.

Yes, please, it would be nice for other users :)


I added step-by-step instructions to the question above for now.