Is this possible with log4j?
Hello guys!I had to rush from work today with out solving this issue.
I tried to configure my JBoss 5 in the jboss-log4j.xml to produce 2 separate log files.
1 for a ear (deployed in a separate, ear like company.ear)
1 for a war (deployed in a separate, war like company.war)
...running in the same JBoss.
Below is the snippets from jboss-log4j.xml.
The problem is that logging for the ear shall handle only all classes (from within the ear) that call the log with package starting with:
com.projectx
...and logging for the war shall handle only all classes (from within the war) that call the log with package starting with:
com.projectx.web
But what I end up with is one nice log file (web.log) with all logging from the war.
...AND a not so nice log file (server.log) with logging from both the ear and war.
I guess this is because of the package got the same starting.
I of course want them totally separated.
So if you got any solutions for this please let me know.
I hope I do not need to force the server to change the package-name.
Best regards
Fredrik
<appender name="WEB-ROLLINGFILE" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="${jboss.server.log.dir}/web.log"/>
<param name="Append" value="true"/>
<param name="MaxFileSize" value="500KB"/>
<param name="maxBackupIndex" value="10"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d{ISO8601} %-5p %.25c{1}->%.25M - %m%n"/>
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="debug" />
<param name="LevelMax" value="fatal" />
<param name="AcceptOnMatch" value="true" />
</filter>
<filter class="org.apache.log4j.varia.DenyAllFilter"/>
</appender>
<appender name="SERVER-ROLLINGFILE" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="${jboss.server.log.dir}/server.log"/>
<param name="Append" value="true"/>
<param name="MaxFileSize" value="500KB"/>
<param name="maxBackupIndex" value="10"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d{ISO8601} %-5p %.25c{1}->%.25M - %m%n"/>
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="debug" />
<param name="LevelMax" value="fatal" />
<param name="AcceptOnMatch" value="true" />
</filter>
<filter class="org.apache.log4j.varia.DenyAllFilter"/>
</appender>
<category name="com.projectx.web">
<level value="DEBUG" />
<appender-ref ref="WEB-ROLLINGFILE"/>
</category>
<category name="com.projectx">
<level value="DEBUG"/>
<appender-ref ref="SERVER-ROLLINGFILE"/>
</category>
