Results 1 to 2 of 2

Thread: Log4j

  1. #1
    chakri is offline Member
    Join Date
    Jan 2008
    Posts
    1
    Rep Power
    0

    Question Log4j

    Hi,

    Iam new to work with log4j.
    I use JBoss4.2.2 version with my two ear files deployed in it.
    My Jboss-log4j.xml is like this :
    Java Code:
    <appender name="Server_APP1" class="org.jboss.logging.appender.RollingFileAppender">
            <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
            <param name="File" value="${jboss.server.log.dir}/Server_APP1.log"/>
            <param name="Append" value="true"/>
            <param name="MaxFileSize" value="10000KB"/>
            <param name="MaxBackupIndex" value="100"/>
       
            <layout class="org.apache.log4j.PatternLayout">
              <param name="ConversionPattern" value="&#37;d %-5p [%c] %m%n"/>
            </layout>
            
            <filter class="org.jboss.logging.filter.TCLFilter">
    		<param name="AcceptOnMatch" value="true"/>
    		<param name="DeployURL" value="app1.ear"/>
    	</filter>
    	 
    	<filter class="org.apache.log4j.varia.DenyAllFilter"/>
    
    
       </appender>
       
       <appender name="Server_APP2" class="org.jboss.logging.appender.RollingFileAppender">
               <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
               <param name="File" value="${jboss.server.log.dir}/Server_APP2.log"/>
               <param name="Append" value="true"/>
               <param name="MaxFileSize" value="10000KB"/>
               <param name="MaxBackupIndex" value="100"/>
          
               <layout class="org.apache.log4j.PatternLayout">
                 <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
               </layout>
               
               <filter class="org.jboss.logging.filter.TCLFilter">
       		<param name="AcceptOnMatch" value="true"/>
       		<param name="DeployURL" value="app2.ear"/>
       	</filter>
       	 
       	<filter class="org.apache.log4j.varia.DenyAllFilter"/>
       
       </appender>
    
    .
    .
    .
    <category name="com.app1">
          <priority value="INFO"/>
          <appender-ref ref="Server_APP1"/>
       </category>
       
       <category name="com.app2" >
             <priority value="INFO"/>
             <appender-ref ref="Server_APP2"/>
       </category>
    
    I have added both Server_APP1,Server_APP2 to root.
    
    I have not used any logger class in application. with above settings iam able to get logs to two different files.
    
    My problem is i use a jar subapplication.jar in app1.
    i like to seperate the info associated with this jar to a different log file.
    
    For this i have added different section for jboss-log4j.xml
    
    <appender name="Server_APP1_New" class="org.jboss.logging.appender.RollingFileAppender">
               <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
               <param name="File" value="${jboss.server.log.dir}/Server_new.log"/>
               <param name="Append" value="true"/>
               <param name="MaxFileSize" value="10000KB"/>
               <param name="MaxBackupIndex" value="100"/>
          
               <layout class="org.apache.log4j.PatternLayout">
                 <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
               </layout>
               
               <filter class="org.jboss.logging.filter.TCLFilter">
       		<param name="AcceptOnMatch" value="true"/>
       		<param name="DeployURL" value="app1.ear"/>
       	</filter>
       	 
       	<filter class="org.apache.log4j.varia.DenyAllFilter"/>
       
       
       </appender>
    
    <!-- com.chakri is package used in subapplication.jar -->
    <category name="com.chakri" additivity="false">
             <priority value="INFO"/>
             <appender-ref ref="Server_APP1_New"/>
       </category>
    i have not added this to root.

    SOme classes of jar have logger initialized with that particular class name.

    eg: static Logger logger = Logger.getLogger(vemuri.class);

    With this changes the data is written to new log file(Server_new.log) only when i use logger.log,logger.info etc. All the exceptions are appended to Server_APP1.log file only i.e the log file for application1 where iam internally using subapplication.jar.

    How can i make all the data related to jar written to seperate file?

    Can any one suggest what wrong with my approach? New approach to solve my problem also appreciated.

    Thanks in Advance,
    Chakri
    Last edited by roots; 01-23-2008 at 06:30 AM.

  2. #2
    vijaiah is offline Member
    Join Date
    Feb 2008
    Posts
    1
    Rep Power
    0

    Default Help

    Hello Chakri,
    When i try to implement the same appender and catagory, in my case it is writing the log to boot.log instead of the mentioned log file?

    Do you have any suggestion for that?

    Thanks
    -Vijay

Similar Threads

  1. log4j
    By swapna_d in forum New To Java
    Replies: 7
    Last Post: 08-04-2010, 12:23 AM
  2. Regarding Log4j
    By sidiq in forum New To Java
    Replies: 0
    Last Post: 04-07-2008, 07:35 PM
  3. log4j with Applet
    By sunjavaboy in forum Java Applets
    Replies: 0
    Last Post: 03-25-2008, 12:13 AM
  4. Help log4j SysLogAppender
    By arthik_babu in forum New To Java
    Replies: 0
    Last Post: 11-19-2007, 01:51 PM
  5. Problems using log4j
    By fred in forum Advanced Java
    Replies: 1
    Last Post: 08-06-2007, 03:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •