Configuring Log4J

Configuring Log4J

Is it possible to configure xml file in such a way that it has different logging levels for diferent packages in java through Log4J ?

View Answers

February 29, 2012 at 11:29 AM


<--configure path according to your requrmts to save log file -->

<appender name="daoAppender" 
   class="org.apache.log4j.RollingFileAppender">   
    <param name="maxFileSize" value="100KB" />   
    <param name="maxBackupIndex" value="2" />   
    <param name="File" value="${jboss.server.home.dir}/deploy/myexampleprj.war/serverlogs/serverlogs.txt" />   
    <layout class="org.apache.log4j.PatternLayout">   
        <param name="ConversionPattern"  
               value="%d{dd-MMM-yyyy HH:mm};%5p %c %m%n" />   
    </layout>   
</appender>   

  <--configure path according for diff packge to your requrmts to save log file -->   

<!--appender name="appAppender"  
          class="org.apache.log4j.RollingFileAppender">   
    <param name="maxFileSize" value="100KB" />   
    <param name="maxBackupIndex" value="2" />   
    <param name="File" value="${jboss.server.home.dir}/deploy/myexampleprj.war/serverlogs/serverlogs.txt" />   
    <layout class="org.apache.log4j.PatternLayout">   
        <param name="ConversionPattern"  
               value="%d{ABSOLUTE} %5p %c{1}: %m%n " />   
    </layout>    
</appender-->   

<!??package name given in category here com is the package give package name  -->    

<!--category name="com.ex.actions">     
    <priority value="DEBUG"/>     
    <appender-ref ref="appAppender"/>       
</category-->

<category name="com">     
    <priority value="DEBUG"/>     
    <appender-ref ref="daoAppender"/>       
</category>    

<root>   
    <!--     
    <appender-ref ref="appAppender" />   
    <appender-ref ref="daoAppender" />   
    -->    
</root>

Ads









Related Tutorials/Questions & Answers:
Configuring Log4J
Configuring Log4J  Is it possible to configure xml file in such a way that it has different logging levels for diferent packages in java through Log4J
log4j
log4j  explain about log4j with example ?   Please visit the following link: log4j Tutorials
Advertisements
Log4j
Log4j  what is the use of log4j in realtime?   Please visit the following link: Log4j Tutorials
LOG4J
LOG4J  HOW AND WHERE TO FIND org.prot.appserver.config.Configuration; PACKAGE TO IMPORTIN LOG4J PREOGRAM
Version of log4j>log4j dependency
List of Version of log4j>log4j dependency
Installing the Driver and Configuring the CLASSPATH
Installing the Driver and Configuring the CLASSPATH  What is the procedure to Installing the Driver and Configuring the CLASSPATH mysql jdbc connector? the jar file
Log4J Architecture - Introduction to the Log4J architecture
. Configuring Log4J For running application using Log4J you need... Log4J Architecture - Introduction to the Log4J architecture... will learn about the architectural component of Log4J. Understanding
configuring a dll file in java.library.path
configuring a dll file in java.library.path  I am unable to configure .dll file in java.library.path in myeclipse ide tool
Artifacts of log4j
List of Artifacts of log4j maven depenency
java - Log4J
regarding "LOG4J" and where these are exactly used in realtime application... as posible.   Hi Friend, Log4j is a logging package to help..., an OutputStream, a java.io.Writer etc. Using Log4j it is possible to enable logging
About configuring Servlet
About configuring Servlet  Hi I culdn't run Apache Tomcat (i already installed Tomcat 5.0 version) on Internet Browser.when i finished installing Tomcat i typed http://local host:8080/ in the internet Browser
Steps to log4j configuration in Struts2
Steps to log4j configuration in Struts2  Hi... any tel me each step for configure log4j in struts2 application
Maven Dependency log4j >> 1.1.3
You should include the dependency code given in this page to add Maven Dependency of log4j >> log4j version1.1.3 in your project
Maven Dependency log4j >> 1.2.11
You should include the dependency code given in this page to add Maven Dependency of log4j >> log4j version1.2.11 in your project
Maven Dependency log4j >> 1.2.12
You should include the dependency code given in this page to add Maven Dependency of log4j >> log4j version1.2.12 in your project
Maven Dependency log4j >> 1.2.13
You should include the dependency code given in this page to add Maven Dependency of log4j >> log4j version1.2.13 in your project
Maven Dependency log4j >> 1.2.14
You should include the dependency code given in this page to add Maven Dependency of log4j >> log4j version1.2.14 in your project
Maven Dependency log4j >> 1.2.15
You should include the dependency code given in this page to add Maven Dependency of log4j >> log4j version1.2.15 in your project
Maven Dependency log4j >> 1.2.16
You should include the dependency code given in this page to add Maven Dependency of log4j >> log4j version1.2.16 in your project
Maven Dependency log4j >> 1.2.17
You should include the dependency code given in this page to add Maven Dependency of log4j >> log4j version1.2.17 in your project
Maven Dependency log4j >> 1.2.4
You should include the dependency code given in this page to add Maven Dependency of log4j >> log4j version1.2.4 in your project
Maven Dependency log4j >> 1.2.5
You should include the dependency code given in this page to add Maven Dependency of log4j >> log4j version1.2.5 in your project
Maven Dependency log4j >> 1.2.6
You should include the dependency code given in this page to add Maven Dependency of log4j >> log4j version1.2.6 in your project
Maven Dependency log4j >> 1.2.7
You should include the dependency code given in this page to add Maven Dependency of log4j >> log4j version1.2.7 in your project
Maven Dependency log4j >> 1.2.8
You should include the dependency code given in this page to add Maven Dependency of log4j >> log4j version1.2.8 in your project
Maven Dependency log4j >> 1.2.9
You should include the dependency code given in this page to add Maven Dependency of log4j >> log4j version1.2.9 in your project
Version of log4j>apache-log4j-extras dependency
List of Version of log4j>apache-log4j-extras dependency
Difficulty in plugging log4J with Hibernate.
Difficulty in plugging log4J with Hibernate.  I am using Hibernate 3.6. Followed your all instruction of plugging log4j with my hibernate code... HandlingWorker, it uses SLF4j and does not detect log4J. What could
log4j in web application
log4j in web application  Hi all, I am new to log4j. I want to use log4j in my web application. I need to write the debug,info,warn into a file. But i don't know how to do the same. Please send one example with explaination
Log4J Tutorials: Using Log4J in Easy Steps
Log4J Tutorials: Using Log4J in Easy Steps Log4j is a logging library for Java... Software Foundation. Log4j is one of best Java logging frameworks used... statements into the code. Log4j has been designed with three objectives to provide
Maven dependency for log4j - log4j version 1.2.15 is released. Learn to use log4j version 1.2.15 in Maven based Java projects
Maven dependency for  log4j  - Version 1.2.15 of log4j released The developers of   log4j - log4j project have released the latest version of this library on 30 Aug 2007, the released version of  log4j - log4j

Ads