Hi, Hmm... I'm getting the feeling you don't fully understand what you're doing (no offence). You are naming your loggers and your appenders to something that looks a lot like logging levels, which at the very least makes things confusing when, as a human, you're trying to understand what is going on, but at worst might cause problems because the configurator might understand what you mean to be a logger or an appender as a log level, and vice versa. Also, by using only two loggers, you are throwing away one of the biggest advantages of log4j, which is granularity of logging statements, i.e., being able to "zoom in" on a part of your program. My best advice to you is, stick with the convention of naming loggers after the class they are used in. Have a read through the short introduction to Log4J, it's really the foundation you need when starting to use log4j. http://logging.apache.org/log4j/docs/manual.html
The one problem I spot is that you're not specifying a filename for your rolling file appender, which means anything you write to your MAIN logger wouldn't be logged anywhere. Otherwise, purely syntactically, I think your config is OK (but I'm relatively new to log4j as well, plus I mainly use XML config files), but I think a line like this: log4j.rootLogger=NORMAL, DEBUG might actually cause trouble, because although you've defined both NORMAL and DEBUG as appenders, DEBUG is also a logging level, which could confuse the configurator. I would create loggers and appenders with all different names (loggers preferably just named after the class they're used in, you should distinguish the severity of a message by the log level, not by using a different logger). So, no overlapping terms for log levels, loggers and appenders, and see if you can get things to work then. Best regards, Eelke Blok -----Original Message----- From: ying lcs [mailto:[EMAIL PROTECTED] Sent: dinsdag 7 november 2006 6:03 To: [email protected] Subject: How to configure 2 logger in the same configuration property file Hi, I am new to log4j. Can you please tell me how can i configure 2 loggers in the same properties file: I have code like this, I only have 2 loggers in my whole application: Logger normalCaseLogger = Logger.getLogger("NORMAL"); normalCaseLogger.info("normal case logging"); Logger debugLogger = Logger.getLogger("DEBUG"); debugLogger.info("debugging logging"); I have try my properties like this, but nothing get print out: log4j.rootLogger=NORMAL, DEBUG log4j.appender.NORMAL=org.apache.log4j.FileAppender log4j.appender.NORMAL.layout=org.apache.log4j.PatternLayout # Print the date in ISO 8601 format log4j.appender.NORMAL.layout.ConversionPattern=%d [%t] %-5p %c - %m%n # Print only messages of level WARN or above in the package com.foo. log4j.logger.NORMAL=INFO log4j.appender.DEBUG =org.apache.log4j.ConsoleAppender log4j.logger.DEBUG = DEBUG Thanks for any help. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] PRIVACY: The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or priviliged material. Any review, retransmission, dissemination or other use of this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. Thank you. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
