You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Alex Gout (JIRA)" <ji...@apache.org> on 2014/03/23 23:19:42 UTC

[jira] [Created] (LOG4J2-575) Log4J2 and Tomee Plus 7.0.47 not working

Alex Gout created LOG4J2-575:
--------------------------------

             Summary: Log4J2 and Tomee Plus 7.0.47 not working
                 Key: LOG4J2-575
                 URL: https://issues.apache.org/jira/browse/LOG4J2-575
             Project: Log4j 2
          Issue Type: Bug
          Components: Core
    Affects Versions: 2.0-rc1
            Reporter: Alex Gout


According to http://logging.apache.org/log4j/2.x/manual/webapp.html, Log4j2 should work with Tomcat7.0.47. I'm using TomEE Plus 7.0.47.

I have a webapplication deployed with a log4j2.xml in my web-inf/classes folder. This is the config:

    <?xml version="1.0" encoding="UTF-8"?>
    <Configuration status="WARN">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
        </Console>
        <File name="File" fileName="${sys:catalina.home}/logs/testapp.log">
            <PatternLayout>
                <pattern>%d %p %C{1.} [%t] %m%n</pattern>
            </PatternLayout>
        </File>
    </Appenders>
    <Loggers>
        <Logger name="org.alex" level="TRACE" additivity="false">
            <AppenderRef ref="File"/>
        </Logger>
        <Root level="INFO">
            <AppenderRef ref="Console"/>
        </Root>
    </Loggers>
    </Configuration>

I have a logger declared in a class with name org.alex.util.JSON:

    private static final Logger LOG = LoggerFactory.getLogger(JSON.class);

I'm using slf4j-api 1.7.5, and have the following libs added to the tomcat lib:

slf4j-api-1.7.5.jar
log4j-api-2.0-rc1.jar
log4j-core-2.0-rc1.jar
log4j-slf4j-impl-2.0-rc1.jar

If I change the Configuration status to TRACE, I can see my configuration file being picked up and configuration happens as expected. Also I can see the MBeans being added.
However, there's not one logging statement ending up in my logfile (although the file is created). I debugged into the log4j2 Logger, and see that the isEnabled(...) method return false because the logger (com.alex.util.JSON) has the level "ERROR" set, while the configuration set the package org.alex to TRACE.
Further investigation shows it uses a DefaultConfiguration configured for level=ERROR, and only root is configured. I'm thinking of a classloader issue, but I can't seem to figure out what the cause is and how to solve it.
Does anyone know what I'm doing wrong?

Furthermore I noticed that the classloader for the instance of my logger that is created at configuration is org.apache.openejb.core.TempClassLoader, while the classloader of the Logger that is invoked is org.apache.catalina.loader.StandardClassLoader. I don't know enough of the whole mechanism to judge whether or not this is to be expected



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org