I use JBoss 5.2 and whenever I log something, slf4j outputs a nested log message, eg
private final static Logger logger = LoggerFactory.getLogger(MyClass.class);
...
logger.info("FOOBAR")
will result in the log message:
2015-06-11 09:54:37,154 INFO [STDOUT] (quartzScheduler_Worker-1) 09:54:37,154 INFO [MyClass] FOOBAR
The inner message is the correct one, why does the outer say that the logging class is STDOUT?
Non-project classes (library-classes) log messages look fine eg,
2015-06-11 09:54:16,538 FINE [javax.activation] (quartzScheduler_Worker-1) MailcapCommandMap: load DEF
Here is my log4j settings file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="File" value="server.log"/>
<param name="Append" value="true"/>
<param name="Threshold" value="DEBUG"/>
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n"/>
</layout>
</appender>
<root>
<priority value="DEBUG"/>
<appender-ref ref="FILE" />
</root>
</log4j:configuration>
I solved it by excluding JBoss version of slf4j. I still have multiple versions of SLF4J, but it seems to work.
2015-06-11 12:30:09,540 ERROR [STDERR] (main) SLF4J: Class path contains multiple SLF4J bindings.
To exclude JBoss slf4 I created the file WEB-INF/jboss-deployment-structure.xml with the contents:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.slf4j" />
</exclusions>
</deployment>
</jboss-deployment-structure>
This site was very helpful http://ankitagarwal.com/wordpress/2012/05/20/using-your-own-instance-of-log4j-in-your-war-on-jboss-as-7-x-2/ .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.