I would like to ask you a question about logging provided jars.
I have maven application with many dependencies and i need to log it by using logback. I work on jboss 5.1.
Almost everything works perfectly fine. I can log all actions from my packets by using logback.xml file and adequate appenders etc. 🙂
There is one problem – I cannot log org.hibernate actions by using logback. It seems to log itself by using log4j in jboss (jboss-log4j.xml configures that).
In my pom.xml i have org.hibernate in scope provided – it is provided by jboss naturally.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.1.GA</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.4.0.GA</version>
<scope>provided</scope>
</dependency>
Snippet from logback.xml
<logger name="org.hibernate" level="TRACE" additivity="false">
<appender-ref ref="SQL_FILE" />
</logger>
When i delete
<scope>provided</scope>
from pom.xml it starts to log using logback.xml in project configuration. I would do that, but i have to use provided jars instead of my own.
Is there any possibility to log provided jars by using in-project configuration? Or am I doomed and i have to use log4j configuration in jboss directory?
To my knowledge, you cannot change the logging configuration of Hibernate which is packaged with JBoss. This Hibernate classes are shared among applications and it’s logging sybsystem has been initialized earlier than your application has been deployed. When you remove
<provided>scope Hibernate becomes the part of your application deployment and is initialized when your application is started. In this case you can re-configure the logging. Hibernate usesslf4jlogger, look around how it can be configured.