I'm am having trouble logging using my appenders defined on my XML log4j configuration file.
I created the jboss-deployment-structure.xml on my EAR's META-INF folder with no sucess.
The jboss-deployment-structure.xml structure is:
<jboss-deployment-structure>
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
<deployment>
<exclusions>
<module name="org.apache.log4j" slot="main"/>
</exclusions>
</deployment>
</jboss-deployment-structure>
I have even tried to edit my standalone.conf.bat file adding the following line:
set "JAVA_OPTS=%JAVA_OPTS% -Dorg.jboss.as.logging.per-deployment=false"
My application deployment is like this:
-> MyAppEAR.ear
-> META-INF
-> MANIFEST.MF
-> MyAoo.war
-> META-INF
-> MANIFEST.MF
-> jboss-deployment-structure.xml
-> WEB-INF
-> web.xml
-> lib
-> log4j-1.2.17.jar
-> ---
-> classes
-> log4j.xml
-> ...
I've noticed the following error:
I even tried migrating from JBOSS 7.1.0 to 7.1.1
Some help please!
Thanks
Thanks for the repply James.
I did what you said and moved the jboss-deployment-structure.xml file to MyAppEAR.ear/META-INF.
I've noticed that this way the exception:
jboss-deployment-structure.xml in subdeployment ignored. jboss-deployment-structure.xml is only parsed for top level deployments.
... doesn't occur. I don't know if that means that the file was parsed... how can I tell?
Despite of this new behaviour my log4j.xml configuration file still isn't loaded and the logger used still is Log4J's.
I know this becaused I wrote to the console:
System.out.println(Logger.getRootLogger().getClass().toString())
...and got:
class org.jboss.logmanager.log4j.BridgeLogger
I've also tried:
Any more ideas?
Thanks
Hi RedEagle see the following configuration which i have tested and its working fine...
Step-1
Create a new module as
jboss-as-7.1.1.Final/modules/com/company/mylog/main/
-module.xml
-log4j-1.2.14.jar
Content of module.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.company.mylog">
<resources>
<resource-root path="log4j-1.2.14.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
Step-2 Now IN my.ear/META-INF/
-jboss-deployment-structure.xml
-MANIFEST.MF
content of jboss-deployment-structure.xml
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
</deployment>
<sub-deployment name="MyWeb.war">
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
</sub-deployment>
<sub-deployment name="MyBeans.jar">
<exclusions>
<module name="org.apache.log4j" />
</exclusions>
</sub-deployment>
</jboss-deployment-structure>
Content of MANIFEST.MF
Manifest-Version: 1.0
Dependencies: com.company.mylog
Step-3 Content of MyLogger.java
public static Logger getLogger(String name) {
Logger logger= LogManager.getLogger(name);
PropertyConfigurator.configure("log4j.properties"); //Path to log4j.properties as many option available in my case for testing i used static path /home/gyani/log4j.properties
return logger;
}
Step-4 Here is log4j.properties
log4j.rootLogger=info,gyani
log4j.appender.gyani=org.apache.log4j.RollingFileAppender
log4j.appender.gyani.File=/home/gyani/myserverlog.log
log4j.appender.gyani.Append=true
log4j.appender.gyani.MaxFileSize=100000KB
log4j.appender.gyani.MaxBackupIndex=10
log4j.appender.gyani.layout=org.apache.log4j.PatternLayout
log4j.appender.gyani.layout.ConversionPattern=[%d{MMM d HH:mm:ss yyyy}] [%-5p] [%c]: %m%n
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