I using common logging and jboss eap 6.2 in java application, log file is creating but empty and hibernate log also not working.
This is my jboss-deployment-structure.xml
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.apache.commons.logging"/>
<module name="org.apache.log4j"/>
</exclusions>
</deployment>
<sub-deployment name="abc.war">
<exclusions>
<module name="org.apache.log4j"/>
<module name="org.apache.commons.logging"/>
</exclusions>
</sub-deployment>
</jboss-deployment-structure>
and this is my log4j.properties
log4j.rootLogger=DEBUG, FILE
log4j.appender.FILE=org.apache.log4j.RollingFileAppender
log4j.appender.FILE.File=c\:\\log\\eSocietySQLLog.log
log4j.appender.FILE.ImmediateFlush=true
log4j.appender.FILE.Threshold=debug
log4j.appender.FILE.Append=true
log4j.appender.FILE.MaxFileSize=10MB
log4j.appender.FILE.MaxBackupIndex=5
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p %c %n%m%C
log4j.appender.FILE.DatePattern='.' yyyy-MM-dd-a
and add JAVA_OPTS="$JAVA_OPTS -Dorg.jboss.as.logging.per-deployment=false" in standalone.conf of jboss eap 6.2.
I got the answer, my log4j is working.
1) I create the module in my jboss eap 6.2 GA jboss_home/modules/com
module is log4j/mylog4j/main
in main folder putted the module.xml
file and log4j-1.2.16.jar
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.fourthdti.esociety">
<resources>
<resource-root path="log4j-1.2.16.jar"/>
</resources>
<dependencies>
<module name="org.apache.log4j"/>
<module name="javax.api"/>
</dependencies>
</module>
2) Add the single line code at end file standalone.conf
which is in JBOSS_HOME/bin
JAVA_OPTS="$JAVA_OPTS -Dorg.jboss.as.logging.per-deployment=false"
3) Create the jboss-deployment-structure.xml
in my META_INF
of ear
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<deployment name="eSociety-ear.ear">
<dependencies>
<module name="com.log4j.mylog4j" export="true" />
</dependencies>
<exclusions>
<module name="org.apache.log4j" />
<module name="org.apache.commons.logging" />
<module name="org.slf4j" />
<module name="org.jboss.logging" />
<module name="org.antlr"/>
<module name="org.hibernate.*"/>
</exclusions>
</deployment>
<sub-deployment name="abc-ejb-0.0.1-SNAPSHOT.jar">
<exclusions>
<module name="org.apache.log4j" />
<module name="org.apache.commons.logging" />
<module name="org.slf4j" />
<module name="org.jboss.logging" />
<module name="org.antlr"/>
<module name="org.hibernate.*"/>
</exclusions>
</sub-deployment>
<sub-deployment name="abc-web-0.0.1-SNAPSHOT.war">
<exclusions>
<module name="org.apache.log4j" />
<module name="org.apache.commons.logging" />
<module name="org.slf4j" />
<module name="org.jboss.logging" />
<module name="org.antlr"/>
<module name="org.hibernate.*"/>
</exclusions>
</sub-deployment>
</jboss-deployment-structure>
4) Putted log4j.properties
in my class path
log4j.rootLogger=DEBUG, FILE, stdout
log4j.logger.org.hibernate=debug
log4j.logger.org.springframework=debug
log4j.logger.org.hibernate.hql.ast.AST=info
log4j.logger.org.hibernate.SQL=trace
log4j.logger.org.hibernate.type= trace
log4j.logger.org.hibernate.tool.hbm2ddl=warn
log4j.logger.org.hibernate.hql=debug
log4j.logger.org.hibernate.cache=info
log4j.logger.org.hibernate.jdbc=debug
#log4j.logger.org.hibernate.jdbc=trace
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.appender.FILE=org.apache.log4j.RollingFileAppender
log4j.appender.FILE.File=c\:\\log\\eSociety.log
log4j.appender.FILE.ImmediateFlush=true
log4j.appender.FILE.Threshold=debug
log4j.appender.FILE.Append=true
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c - %m%n
log4j.appender.FILE.MaxFileSize=10MB
log4j.appender.FILE.MaxBackupIndex=2
5) Add dependencies in pom.xml
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.10</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.4</version>
</dependency>
It is enough for my log4j configuration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With