Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use my log4j under jboss 6

I want to deploy my web application on JBOSS6. The applicaation itself works, but the logging doens't. I use log4j and have added a jboss-deployment-structure.xml to my war. The contents are

<jboss-deployment-structure>
<deployment>
    <!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
    <exclusions>
        <module name="org.apache.log4j" />
        <module name="org.jboss.logging" />
    </exclusions>
</deployment>

In my log4j.xml I have

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "dtd/log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<appender name="LogAppender" class="org.apache.log4j.RollingFileAppender">
    <param name="File" value="C:\\logs\\web.log"/>
    <param name="MaxFileSize" value="10000KB"/>
    <param name="MaxBackupIndex" value="10"/>
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%x %-5p [%d{yyyyMMdd HH:mm:ss}] - %c:%L - %m%n"/>
    </layout>
</appender>

<logger name="be.sofico.web">
    <level value="debug" />
    <appender-ref ref="LogAppender" />
</logger>

This all works fine on tomcat and websphere (when I set classloading parent last)

How can I get it to work on JBOSS 6?

like image 370
roel Avatar asked Aug 20 '12 14:08

roel


1 Answers

I solved my problem doing the following: put jboss-deployment-structure.xml inside web\META-INF with the following in the file

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
  <deployment>
    <exclusions>
        <module name="org.apache.log4j" />
        <module name="org.apache.commons.logging" />
    </exclusions>
  </deployment>
</jboss-deployment-structure>

And add this to the startup of the server: -Dorg.jboss.as.logging.per-deployment=false

like image 58
roel Avatar answered Sep 28 '22 03:09

roel