You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Brendon Co <Br...@asia.bigfoot.com> on 2003/06/05 10:46:52 UTC

RE: log different file

Do you have a sample configuration that I can refer to?

thanks,
-brendon

-----Original Message-----
From: Scott Heaberlin [mailto:heabdogg@yahoo.com]
Sent: Thursday, May 29, 2003 7:21 PM
To: 'Log4J Users List'
Subject: RE: log different file


There are a couple of ways to control which logging events go into
certain files (more specifically, certain appenders).

You could specify named Loggers with package or class names in your
log4j config file such that output from certain packages or classes
are
printed to separate files.

You could also extend the Filter class and attach filters to your
appenders in your config file so that logging events are "routed" to
separate appenders / files depending on content, level... the
possibilities are endless with this approach.

We've been using custom filter classes to distribute log output to
several files based on NDC and MDC values.  I was pleasantly surprised
to see similar ones added to the log4j-sandbox in recent months.


-Scott Heaberlin


> -----Original Message-----
> From: Ramadoss Chinnakuzhandai 
> [mailto:ramadoss.chinnakuzhandai@wipro.com] 
> Sent: Thursday, May 29, 2003 2:47 AM
> To: Log4J Users List
> Subject: RE: log different file
> 
> 
> 
> Hi Brendon,
> I suppose if you(program)want to decide which file to log 
> then you could probably define property/xml file and 
> configure it explicitly since default log4j.properties/xml 
> will write the same contents onto both 
> files(xxx.log,yyy.log)irrespective of which one to chose and 
> write. Since you are loading it explicitly you can define 
> which file to write.
> 
> HTH,
> Ram
> 
> 
> 
> -----Original Message-----
> From: Brendon Co [mailto:Brendon.Co@asia.bigfoot.com] 
> Sent: Thursday, May 29, 2003 10:36 AM
> To: Log4J Users List
> Subject: RE: log different file
> 
> 
> Hi Ram,
> 
> Thanks for the info but i already tried this configuration 
> and it turns out the logging are the same...
> 
> xxx.log content the same with yyy.log
> 
> What i like to know is that how will my class determine which 
> log file to use? If i want to log to xxx.log or yyy.log, how 
> will i point to this file?
> 
> 
> Any ideas, please help.
> 
> 
> Thanks,
> brendon
> 
> -----Original Message-----
> From: Ramadoss Chinnakuzhandai 
> [mailto:ramadoss.chinnakuzhandai@wipro.com]
> Sent: Thursday, May 29, 2003 12:49 PM
> To: Log4J Users List
> Subject: RE: log different file
> 
> 
> 
> Hi Brendon,
>                  Basically if you want to log onto different 
> file declare different appender both write into different 
> file and these appenders could be FileAppender or 
> RollingFileAppender or CompositeFileAppender. 
> 
> For example..
> 
> log4j.rootCategory=debug, A1, A2 
> log4j.appender.A1=org.apache.log4j.DailyRollingFileAppender
> log4j.appender.A1.File=xxx.log 
> log4j.appender.A1.DatePattern='.'yyyy-MM-dd
> log4j.appender.A1.layout=org.apache.log4j.PatternLayout
> log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - 
> %m%n log4j.appender.A1.MaxFileSize=10MB
> log4j.appender.A1.MaxBackupIndex=3
> 
> log4j.appender.A2=org.apache.log4j.DailyRollingFileAppender
> log4j.appender.A2.File=yyy.log 
> log4j.appender.A2.DatePattern='.'yyyy-MM-dd
> log4j.appender.A2.layout=org.apache.log4j.PatternLayout
> log4j.appender.A2.layout.ConversionPattern=%d [%t] %-5p %c - 
> %m%n log4j.appender.A2.MaxFileSize=10MB
> log4j.appender.A2.MaxBackupIndex=3
> 
> There will be a two log file xxx.log and yyy.log.
> 
> Hope this helps..
> 
> Reg,
> Ram
> 
> 
> 
> -----Original Message-----
> From: Brendon Co [mailto:Brendon.Co@asia.bigfoot.com] 
> Sent: Thursday, May 29, 2003 7:24 AM
> To: Log4J Users List
> Subject: log different file
> 
> 
> Hi,
> 
> How do i log different file?
> 
> Below is my current configuration.... 
>
======================================================================
> ===========================
> 
> log4j.rootCategory=debug, A1, A2
> 
> #### appender writes to a file
> 
> log4j.appender.A1=org.apache.log4j.DailyRollingFileAppender
> log4j.appender.A1.File=xxx.log 
> log4j.appender.A1.DatePattern='.'yyyy-MM-dd
> log4j.appender.A1.layout=org.apache.log4j.PatternLayout
> 
> 
> #### Should i do it this way?
> 
> log4j.appender.A2=org.apache.log4j.DailyRollingFileAppender
> log4j.appender.A2.File=xxx.log 
> log4j.appender.A2.DatePattern='.'yyyy-MM-dd
> log4j.appender.A2.layout=org.apache.log4j.PatternLayout
> 
> 
> # Control the maximum log file size
log4j.appender.A1.MaxFileSize=10MB
> 
> 
> # Should i do it this way?
> log4j.appender.A2.MaxFileSize=10MB
> 
> 
> # Archive log files (one backup file here) 
> log4j.appender.A1.MaxBackupIndex=3
> 
> 
> # Should i do it this way?
> log4j.appender.A2.MaxBackupIndex=3
> 
> # Note the %x conversion specifier for NDC printing. 
> #log4j.appender.A1.layout.ConversionPattern=%-4r %-5p [%t] 
> (%x) - %m\n log4j.appender.A1.layout.ConversionPattern=%d 
> [%t] %-5p %c - %m%n
> 
> # Should i do it this way? 
> log4j.appender.A2.layout.ConversionPattern=%d
> [%t] %-5p %c - %m%n
> 
>
======================================================================
> ===========================
> 
> 
> What is the basic way to do it?
> 
> Please help...
> 
> 
> Thanks,
> brendon
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.483 / Virus Database: 279 - Release Date: 5/19/2003
>  
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
> 
> 
>
**************************Disclaimer**********************************
> **
> 
> Information contained in this E-MAIL being proprietary to 
> Wipro Limited is 
> 'privileged' and 'confidential' and intended for use only by 
> the individual  or entity to which it is addressed. You are 
> notified that any use, copying 
> or dissemination of the information contained in the E-MAIL 
> in any manner 
> whatsoever is strictly prohibited.
> 
>
**********************************************************************
> *****
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
> 
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.483 / Virus Database: 279 - Release Date: 5/19/2003
>  
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.483 / Virus Database: 279 - Release Date: 5/19/2003
>  
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
> 
> 
> **************************Disclaimer**************************
> **********
> 
> Information contained in this E-MAIL being proprietary to 
> Wipro Limited is 
> 'privileged' and 'confidential' and intended for use only by 
> the individual  or entity to which it is addressed. You are 
> notified that any use, copying 
> or dissemination of the information contained in the E-MAIL 
> in any manner 
> whatsoever is strictly prohibited.
> 
> **************************************************************
> *************
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.483 / Virus Database: 279 - Release Date: 5/19/2003
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.487 / Virus Database: 286 - Release Date: 6/1/2003
 

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org