C.2. Separate Log Files Per Application

To segregate logging output per application, assign log4j categories to specific appenders. This is typically done in the conf/log4j.xml deployment descriptor.

Example C.2. Filtering App1 Log Output to a Separate File

        <appender name="App1Log" 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/app1.log"/>
  <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
  </layout>
</appender>

...

<category name="com.app1">
  <appender-ref ref="App1Log"></appender-ref>
</category>
<category name="com.util">
  <appender-ref ref="App1Log"></appender-ref>
</category>


			
			
			

Example C.3. Using TCLMCFilter

Enterprise Platform 5.1 includes the new class jboss.logging.filter.TCLMCFilter, which allows you to filter based on the deployment URL.
        <appender name="App1Log" 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/app1.log"/>
  <layout class="org.apache.log4j.PatternLayout">
	 <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
  </layout>
  <filter class="org.jboss.logging.filter.TCLMCFilter">
	 <param name="AcceptOnMatch" value="true"/>
	 <param name="DeployURL" value="app1.ear"/>
  </filter>    
  
  <!-- end the filter chain here -->
  <filter class="org.apache.log4j.varia.DenyAllFilter"></filter>

</appender>