How do I configure jboss log4j to avoid logging into server.log and instead write to a separate log file for a specifc java package? -


problem:-

  • configure jboss log4j log separate log file above referenced java package -- resolved needed advise on solution
  • configure jboss log4j avoid logging server.log specific java package

environment:-

  • app server (jboss eap 5.1) configured , running on oracle linux vm through oracle virtualbox manager.

my approach:-

  • i able configure jboss log separate file modifying jboss-log4j.xml have new appender (mytestlogs) , category package(com.mytestpackage) reference new appender. cannot avoid jboss logging server.log package.

my jboss-log4j.xml:-

   <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">     <!-- ================================= -->    <!-- preserve messages in local file -->    <!-- ================================= -->     <!-- time/date based rolling appender -->    <appender name="file" class="org.jboss.logging.appender.dailyrollingfileappender">       <errorhandler class="org.jboss.logging.util.onlyonceerrorhandler"/>       <param name="file" value="${jboss.server.log.dir}/server.log"/>       <param name="append" value="true"/>       <!-- in 5.0.x server log threshold set system            property. in 5.1 , later instead using system            property set priority on root logger (see <root/> below)       <param name="threshold" value="${jboss.server.log.threshold}"/>       -->        <!-- rollover @ midnight each day -->       <param name="datepattern" value="'.'yyyy-mm-dd"/>        <!-- rollover @ top of each hour       <param name="datepattern" value="'.'yyyy-mm-dd-hh"/>       -->        <layout class="org.apache.log4j.patternlayout">          <!-- default pattern: date priority [category] (thread) message\n -->          <param name="conversionpattern" value="%d %-5p [%c] [%x{sessionid}] (%t) %m%n"/>           <!-- full pattern: date ms priority [category] (thread:ndc) message\n          <param name="conversionpattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>           -->       </layout>    </appender>     <!-- ============================== -->    <!-- append messages console -->    <!-- ============================== -->     <appender name="console" class="org.apache.log4j.consoleappender">       <errorhandler class="org.jboss.logging.util.onlyonceerrorhandler"/>       <param name="target" value="system.out"/>       <param name="threshold" value="info"/>        <layout class="org.apache.log4j.patternlayout">          <!-- default pattern: date priority [category] message\n -->          <param name="conversionpattern" value="%d{absolute} %-5p [%c{1}] %m%n"/>       </layout>    </appender>        <!-- limit jacorb category warn info verbose -->    <category name="jacorb">       <priority value="warn"/>    </category>     <!-- set logging level of jsf implementation uses       | java.util.logging. jdk logging levels can controlled       | through org.jboss.logging.log4j.jdklevel class       | in addition standard log4j levels adds support       | severe, warning, config, fine, finer, finest    -->    <category name="javax.enterprise.resource.webcontainer.jsf">      <priority value="info" class="org.jboss.logging.log4j.jdklevel"/>    </category>     <!-- limit org.jgroups category warn info verbose -->    <category name="org.jgroups">       <priority value="warn"/>    </category>     <!-- limit org.quartz category info debug verbose -->    <category name="org.quartz">       <priority value="info"/>    </category>     <!-- limit com.sun category info fine verbose -->    <category name="com.sun">       <priority value="info"/>    </category>     <!-- limit sun category info fine verbose -->    <category name="sun">       <priority value="info"/>    </category>     <!-- limit javax.xml.bind category info fine verbose -->    <category name="javax.xml.bind">       <priority value="info"/>    </category>     <!-- limit springframework category warn-->    <category name="org.springframework">      <priority value="warn"/>    </category>      <!-- limit jsr77 categories -->    <category name="org.jboss.management">       <priority value="info"/>    </category>     <!-- limit verbose facelets compiler -->    <category name="facelets.compiler">       <priority value="warn"/>    </category>     <!-- limit verbose ajax4jsf cache initialization -->    <category name="org.ajax4jsf.cache">       <priority value="warn"/>    </category>     <!-- limit verbose embedded jopr categories -->    <category name="org.rhq">       <priority value="warn"/>    </category>     <!-- limit verbose seam categories -->    <category name="org.jboss.seam">       <priority value="warn"/>    </category>     <!-- limit verbose mc4j ems (lib used admin-console) categories -->    <category name="org.mc4j.ems">       <priority value="warn"/>    </category>     <!-- limit org.jboss.serial (jboss-serialization) info debug verbose -->    <category name="org.jboss.serial">       <priority value="info"/>    </category>      <!-- ============================================ -->    <!-- setup appender , log file red logs -->    <!-- ============================================ -->      <appender name="mytestlogs" class="org.jboss.logging.appender.dailyrollingfileappender">         <param name="file" value="${jboss.server.log.dir}/mytestlogs.log" />         <param name="append" value="true" />         <param name="datepattern" value="'.'yyyy-mm-dd"/>         <layout class="org.apache.log4j.patternlayout">             <!-- log message pattern -->             <param name="conversionpattern" value="%d %-5p [%c] (%t) %m%n" />         </layout>    </appender>     <category name="com.mytestpackage">      <priority value="info" />      <appender-ref ref="mytestlogs"/>    </category>      <!-- ======================= -->    <!-- setup root category -->    <!-- ======================= -->     <root>       <!--           set root logger priority via system property. note parsed log4j,          full jboss system property format not supported; e.g.          setting default via ${jboss.server.log.threshold:warn} not work.                 -->       <priority value="${jboss.server.log.threshold}"/>       <appender-ref ref="console"/>       <appender-ref ref="file"/>     </root>  </log4j:configuration> 


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -