  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Struts - A MVC web framework | | Tomcat - JSP/Servlet container | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | | JSP - A mailing list about Java Server Pages specification and reference | |
Struts & Hibernate
|
|
|
  | | | Help in log4j multiple out put files | Help in log4j multiple out put files 2004-06-29 - By Manoj Mallawaarachchie
Back
Dear All,
I have little problem with creating and separating log output to multiple log files,
I'm trying to do the separate log out put to files, but my problem is if do the instance one class in main program say A1.class instance A2.class
The logger define to A1.class contain A2.class es log out puts. So how can I avoid this.
Please give me some advice to overcome this issue. I attach my source files with this mail
Thank you, Best regards, Manoj
My config file -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- #log4j.rootLogger=ALL, dest3, dest4
#Catagory Log4j.category.dest4=INFO,dest4 Log4j.category.dest3=WARN,dest3
log4j.additivity.dest4=false log4j.additivity.dest3=false
log4j.appender.dest4.layout=org.apache.log4j.PatternLayout #WRITE LOG TO A FILE, ROLL THE FILE EVERY WEEK log4j.appender.dest4=org.apache.log4j.DailyRollingFileAppender
# Specify the file name log4j.appender.dest4.File=log2222.txt # Control the maximum log file size #log4j.appender.dest3.MaxFileSize=300KB
# Rollover log file at the start of each week log4j.appender.dest4.DatePattern='.'yyyy-MM log4j.appender.dest4.layout.ConversionPattern=%d{yyyy-MM-dd hh:mm:ss}
|%m %n log4j.appender.dest4.Threshold=INFO
log4j.appender.dest3.layout=org.apache.log4j.PatternLayout #WRITE LOG TO A FILE, ROLL THE FILE EVERY WEEK log4j.appender.dest3=org.apache.log4j.DailyRollingFileAppender # Specify the file name log4j.appender.dest3.File=log.txt # Control the maximum log file size #log4j.appender.dest3.MaxFileSize=300KB # Rollover log file at the start of each week log4j.appender.dest3.DatePattern='.'yyyy-MM log4j.appender.dest3.layout.ConversionPattern=%d{yyyy-MM-dd hh:mm:ss}
|%m %n log4j.appender.dest3.Threshold=WARN -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---
******Java main program ******
import org.apache.log4j.Logger ; import org.apache.log4j.PropertyConfigurator ; import org.apache.log4j.Category ;
public class dest3 {
// static Logger logger = Logger.getLogger(getClass());
static Category log = Category.getInstance(dest3.class.getClass());
public static void main(String args[]) {
PropertyConfigurator.configure("config3.txt");
log.warn("Here is some FATAL");
dest4 d4 = new dest4(); /* This method out put should go to second log file, but it contain 2nd //logfile as well as this files(logfile 1) too */
d4.p();
} } -- ---- ---- ---- ---- ---- ---- ----
=========================================================================== To unsubscribe, send email to listserv@(protected) and include in the body of the message "signoff J2EE-INTEREST". For general help, send email to listserv@(protected) and include in the body of the message "help".
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859 (See http://ISO-8859.ora-code.com)-1"> <title></title> </head> <body text="#000000" bgcolor="#ffffff"> <table cellpadding="0" cellspacing="0" border="0" width="9" height="90"> <tbody> <tr> <th valign="baseline" align="right" nowrap="nowrap"><br> </th> <td><br> </td> </tr> <tr> <td></td> </tr> <tr> <th valign="baseline" align="right" nowrap="nowrap"></th> <td><br> </td> </tr> </tbody> </table> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859 (See http://ISO-8859.ora-code.com)-1"> <title></title> Dear All,<br> <br> <br> I have little problem with creating and separating log output to multiple log files,<br> <br> I'm trying to do the separate log out put to files, but my problem is if do the instance one class in main program say A1.class instance A2.class <br> <br> The logger define to A1.class contain A2.class es log out puts. So how can I avoid this.<br> <br> Please give me some advice to overcome this issue. I attach my source files with this mail<br> <br> Thank you,<br> Best regards,<br> Manoj<br> <br> <br> My config file<br> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -----<br> #log4j.rootLogger=ALL, dest3, dest4<br> <br> <br> #Catagory<br> Log4j.category.dest4=INFO,dest4<br> Log4j.category.dest3=WARN,dest3<br> <br> log4j.additivity.dest4=false<br> log4j.additivity.dest3=false<br> <br> <br> log4j.appender.dest4.layout=org.apache.log4j.PatternLayout<br> #WRITE LOG TO A FILE, ROLL THE FILE EVERY WEEK<br> log4j.appender.dest4=org.apache.log4j.DailyRollingFileAppender<br> <br> # Specify the file name<br> log4j.appender.dest4.File=log2222.txt<br> # Control the maximum log file size<br> #log4j.appender.dest3.MaxFileSize=300KB<br> <br> # Rollover log file at the start of each week<br> log4j.appender.dest4.DatePattern='.'yyyy-MM<br> log4j.appender.dest4.layout.ConversionPattern=%d{yyyy-MM-dd hh:mm:ss} <br> <br> |%m %n<br> log4j.appender.dest4.Threshold=INFO<br> <br> <br> log4j.appender.dest3.layout=org.apache.log4j.PatternLayout<br> #WRITE LOG TO A FILE, ROLL THE FILE EVERY WEEK<br> log4j.appender.dest3=org.apache.log4j.DailyRollingFileAppender<br> # Specify the file name<br> log4j.appender.dest3.File=log.txt<br> # Control the maximum log file size<br> #log4j.appender.dest3.MaxFileSize=300KB<br> # Rollover log file at the start of each week<br> log4j.appender.dest3.DatePattern='.'yyyy-MM<br> log4j.appender.dest3.layout.ConversionPattern=%d{yyyy-MM-dd hh:mm:ss} <br> <br> |%m %n<br> log4j.appender.dest3.Threshold=WARN<br> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---<br> <br> ******Java main program ******<br> <br> import org.apache.log4j.Logger ;<br> import org.apache.log4j.PropertyConfigurator ;<br> import org.apache.log4j.Category ;<br> <br> public class dest3 {<br> <br> // static Logger logger = Logger.getLogger(getClass());<br> <br> static Category log = Category.getInstance(dest3.class.getClass());<br> <br> <br> public static void main(String args[]) {<br> <br> PropertyConfigurator.configure("config3.txt"); <br> <br> <br> log.warn("Here is some FATAL");<br> <br> dest4 d4 = new dest4(); <br> /* This method out put should go to second log file, but it contain 2nd //logfile as well as this files(logfile 1) too */<br> <br> d4.p();<br> <br> <br> }<br> }<br> -- ---- ---- ---- ---- ---- ---- ----<br> <br> <small><small><span style="font-weight: bold; font-size: 14pt; font-family: arial,helvetica,sans -serif;"> </span></small></small> </body> </html> =========================================================================== To unsubscribe, send email to listserv@(protected) and include in the body of the message "signoff J2EE-INTEREST". For general help, send email to listserv@(protected) and include in the body of the message "help". <p>
|
|
 |