[
https://issues.apache.org/jira/browse/LOG4J2-172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13593533#comment-13593533
]
Henry Clout commented on LOG4J2-172:
------------------------------------
I figured it out. Hibernate uses jboss logging which invokes the following to
detect if log4j is present (in class org.jboss.logging.LoggerProviders) :
Class.forName("org.apache.log4j.LogManager", true, cl);
// JBLOGGING-65 - slf4j can disguise itself as log4j. Test for a class
that slf4j doesn't provide.
Class.forName("org.apache.log4j.Hierarchy", true, cl);
This fails regardless of whether or not log4j-1.2-api-2.0-beta4.jar is present
as org.apache.log4j.Hierarchy isn't available.
Then it fails to use slf4j as it runs the following:
// only use slf4j if Logback is in use
Class.forName("ch.qos.logback.classic.Logger", false, cl);
So it defaults to using JDK logging.
The workaround I used was to set a system property to force it to use slf4j :
-Dorg.jboss.logging.provider=slf4j
The correct fix, I would think, is for jboss need to incorporate a check for
log4j2 class files.
> Logging doesn't work in Hibernate
> ---------------------------------
>
> Key: LOG4J2-172
> URL: https://issues.apache.org/jira/browse/LOG4J2-172
> Project: Log4j 2
> Issue Type: Bug
> Components: SLF4J Bridge
> Affects Versions: 2.0-beta4
> Environment: OSX, Tomcat 6, Spring, Hibernate
> Reporter: Henry Clout
> Labels: hibernate, slf4j
>
> I've been testing a migration from log4j1.x to log4j 2.0 beta 4. So far I've
> got our application and Spring logging fine using log4j2, but I can't seem to
> get any output from Hibernate (4). Hibernate uses slf4j, so I've included
> the bridge, but alas no go.
> I've included the following jars :
> log4j-api-2.0-beta4.jar
> log4j-core-2.0-beta4.jar
> log4j-slf4j-impl-2.0-beta4.jar
> slf4j-api-1.7.2.jar
> slf4j-ext-1.7.2.jar
> My log4j2.xml is as follows:
> <?xml version="1.0" encoding="UTF-8" ?>
> <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'
> monitorInterval="5" status="debug">
> <appenders>
>
> <Console name="STANDARD_CONSOLE" target="SYSTEM_OUT">
> <PatternLayout pattern="%d [%t] %-5p %20c{1}.%M - %m%n"/>
> </Console>
>
> <RollingFile name="FILE_APPENDER"
> fileName="/Users/henry/Documents/kulu/tools/logs/server.log"
>
> filePattern="/Users/henry/Documents/kulu/tools/logs/server-%i.log">
> <PatternLayout>
> <pattern>%d [%t] %-5p %20c{1}.%M - %m%n</pattern>
> </PatternLayout>
> <Policies>
> <SizeBasedTriggeringPolicy size="500000 KB"/>
> </Policies>
> <DefaultRolloverStrategy max="5"/>
> </RollingFile>
> <SMTP name="EMAIL_APPENDER" suppressExceptions="false" subject="[KVP]
> %c{1}: %m" to="[email protected]"
> from="[email protected]" smtpHost="mail.kuluvalley.com"
> smtpUsername="[email protected]"
> smtpPassword="pw" bufferSize="10">
>
> <BurstFilter rate="0.1" />
> </SMTP>
> </appenders>
> <loggers>
> <logger name="com.kuluvalley" level="warn">
> <appender-ref ref="FILE_APPENDER" />
> <appender-ref ref="STANDARD_CONSOLE" />
> </logger>
> <logger
> name="com.kuluvalley.guru.server.service.common.PackageServiceImpl"
> level="info">
> <appender-ref ref="FILE_APPENDER" />
> </logger>
> <logger name="org.springframework" level="warn">
> <appender-ref ref="FILE_APPENDER" />
> </logger>
> <logger name="org.springframework.security" level="warn">
> <appender-ref ref="FILE_APPENDER" />
> </logger>
> <logger name="org.apache.cxf" level="info">
> <appender-ref ref="FILE_APPENDER" />
> </logger>
> <logger name="org.hibernate" level="debug">
> <appender-ref ref="FILE_APPENDER" />
> <appender-ref ref="STANDARD_CONSOLE" />
> </logger>
> <logger name="org.hibernate.SQL" level="debug">
> <appender-ref ref="FILE_APPENDER" />
> <appender-ref ref="STANDARD_CONSOLE" />
> </logger>
> <root level="info">
> <appender-ref ref="FILE_APPENDER" />
> </root>
>
> </loggers>
> </log4j:configuration>
> Any thoughts as to what could be wrong?
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]