Log to different log files
1 posts in topic
Flat View  Flat View

Posted By:   herman_badenhorst
Posted On:   Tuesday, November 25, 2003 09:08 PM

Hi there,

I need to log certain web applications to their relative log file. Some of the packages are shared among them and others are not. I also need so build logic in for their owns exceptions. This means that Exception A must log as INFO and Exception B must log as WARN. I wrote a single object that will handle this logic, but i struggle now to log to the different log files. Where do i start?

This is my first time using log4j and would appreciate any help.


Re: Log to different log files

Posted By:   ravi_sambandam  
Posted On:   Thursday, December 4, 2003 03:23 AM


i think you want to log your data into two different destinations based on the condition.

This you can do it by defining morethan one logger in your log4j related property file and use the respective logger for logging the data in respective scenarios.

say like u have defined two loggers log1, log2 in the property file.
define the output file name for log1 as c:/log1.log
and the output file name for log2 as c:/log2.log.

in the java class

protected final static Logger log1 = Logger.getLogger("log1");
protected final static Logger log2 = Logger.getLogger("log2");

when u use log1 object , logs will be written to log1.log file and if u use log2 object ,logs will be flushed to log2.log file.

ravi sambandam
About | Sitemap | Contact