aspose file tools*
The moose likes Other Open Source Projects and the fly likes Log4j Grouping application logs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Log4j Grouping application logs" Watch "Log4j Grouping application logs" New topic

Log4j Grouping application logs

M Handa

Joined: Mar 08, 2010
Posts: 3

I am trying to group logs of multiple related applications to a single log file.

For example I have 3 applications A1.esb, A2.esb, A3.esb.

I want all the logs from these 3 applications get logged to a single log file called A.log.

Similarly, I want B.log for B1.esb, B2.esb and B3.esb.

I am using log4j in JBoss application server.

I have tried to use TCLFilter but I only succeeded in getting individual applications logging to individual log files. As in, A1.esb logging to A1.log, A2.esb logging to A2.log and so on. But I couldn't figure out a way of grouping these loggings.
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443


What happens if you give the name of the same file (e.g.: app.log) in the configuration files for all the applications?

M Handa

Joined: Mar 08, 2010
Posts: 3
I have managed to fix it by reading some documentation on log4j for jboss.

All I had to do was to specify an appender per application group and inside each appender, I would have a filter chain.

So my log appender shall look like the following.

<appender name="A" class="org.apache.log4j.FileAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"></errorHandler>
<param name="Append" value="false"/>
<param name="File" value="${jboss.server.home.dir}/log/A.log"/>
<param name="Threshold" value="INFO"/>

<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>

<filter class="org.jboss.logging.filter.TCLFilter">
<param name="AcceptOnMatch" value="true"/>
<param name="DeployURL" value="A1.esb"/>

<filter class="org.jboss.logging.filter.TCLFilter">
<param name="AcceptOnMatch" value="true"/>
<param name="DeployURL" value="A2.esb"/>

<filter class="org.jboss.logging.filter.TCLFilter">
<param name="AcceptOnMatch" value="true"/>
<param name="DeployURL" value="A3.esb"/>

<filter class="org.apache.log4j.varia.DenyAllFilter"/>


and so on for Group B, which would have B1.esb, B2.esb and B3.esb.
I agree. Here's the link:
subject: Log4j Grouping application logs
Similar Threads
Log4j Problem
jboss-log4j: seperate logs for different applications
log4j updating wrong file
J2EE and Logging
Log4j configuration help. Using different log files for different applications