How to create different log files for different levels?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   vipin_sharma
Posted On:   Saturday, April 1, 2006 01:08 AM

Hi, I want to create different log files for different levels. Here is my log4j.properties file. log4j.rootCategory=debug, level_one log4j.appender.level_one=org.apache.log4j.RollingFileAppender log4j.appender.level_one.File=debug.log log4j.appender.level_one.MaxFileSize=100KB log4j.appender.level_one.MaxBackupIndex=10 log4j.appender.level_one.layout=org.apache.log4j.SimpleLayout And my java code is here : import org.apache.log4j.*; class TestLogger { public static Logger logger = Logger.getRootLogger(); public static void main(String[] args) { logger.fatal("fatal Occure   More>>

Hi,
I want to create different log files for different levels. Here is my log4j.properties file.


log4j.rootCategory=debug, level_one
log4j.appender.level_one=org.apache.log4j.RollingFileAppender
log4j.appender.level_one.File=debug.log
log4j.appender.level_one.MaxFileSize=100KB
log4j.appender.level_one.MaxBackupIndex=10
log4j.appender.level_one.layout=org.apache.log4j.SimpleLayout


And my java code is here :



import org.apache.log4j.*;

class TestLogger

{

public static Logger logger = Logger.getRootLogger();


public static void main(String[] args)

{

logger.fatal("fatal Occured");

logger.error("Error Occured");

logger.warn("warn Occured");

logger.info("info Occured");

logger.debug("debug Occured");

}

}

   <<Less

Re: How to create different log files for different levels?

Posted By:   santosh_kumar  
Posted On:   Thursday, April 27, 2006 03:46 AM

Use a LevelMatchFilter

http://mail-archives.apache.org/mod_mbox/logging-log4j-user/200512.mbox/%3C20051221061600.99230.qmail@web32609.mail.mud.yahoo.com%3E

http://www.mail-archive.com/log4j-user@logging.apache.org/msg04878.html

Santosh.

Re: How to create different log files for different levels?

Posted By:   Massimiliano_Ragazzi  
Posted On:   Tuesday, April 4, 2006 12:19 PM

All you have to do is changing the setting for rootCategory


if you set debug only the logger.debug are written

About | Sitemap | Contact