[prev in list] [next in list] [prev in thread] [next in thread] 

List:       log4j-user
Subject:    Re: R: Application with two loggers - The second one doesn't log anything
From:       James Stauffer <stauffer.james () gmail ! com>
Date:       2006-01-19 16:30:17
Message-ID: c83e39890601190830q4599fa8cw39b8e58ba9adf227 () mail ! gmail ! com
[Download RAW message or body]

You only need the -D option to specify the configuration file if you
use automatic configuration.  Since you use
PropertyConfigurator.configureAndWatch, you don't need to use -D.

In your properties file you probably need to specify a level for the
root logger.

On 1/19/06, Pagnin Roberto <Roberto.Pagnin@tilab.com> wrote:
> Hi James, I put the -D<option> because I've read on some forums that the error \
> "Log4j:WARN. No appenders could be found for logger(MyLoggerThread.class) "  is a \
> problem of pointing to the right log4j config file (so this was one of the many \
> tries for solving the trouble).   In the application I configure Log4j in this way: \
>  appPropPath = args[0];
> log4jPropPath = args[1];
> try
> {
> log4jRefreshTime = Long.parseLong(args[2]);
> }
> catch (NumberFormatException ex)
> {
> System.err.println("ERROR - Log4j Refresh Time param. MUST be a number.");
> ex.printStackTrace();
> System.exit(1);
> }
> 
> // Configure log4j for application logging
> PropertyConfigurator.configureAndWatch(log4jPropPath,log4jRefreshTime);
> 
> 
> Thanks
> Rob
> 
> 
> -----Messaggio originale-----
> Da: James Stauffer [mailto:stauffer.james@gmail.com]
> Inviato: mercoledì 18 gennaio 2006 18.08
> A: Log4J Users List
> Oggetto: Re: Application with two loggers - The second one doesn't log anything
> 
> Why is log4j.properties in the command line twice?  Do you use
> automatic configuration?
> 
> On 1/18/06, Pagnin Roberto <Roberto.Pagnin@tilab.com> wrote:
> > The application is a JMS client that logs application messages in a file
> > and JMS received messages in another file.
> > As in subject, my application experiences a problem, the 2nd defined
> > logger doesn't work, and in the working log I've found the message "
> > Log4j:WARN. No appenders could be found for logger
> > (MyLoggerThread.class) ".
> > Is out there anybody that could help me ?  Thank you in advance
> > Here follow some informations.
> > 
> > Launch batch (start.sh)
> > -----------------------
> > #!/bin/sh
> > /usr/j2se/jre/bin/java -cp
> > /opt/test/:/opt/test/mylogger.jar:/opt/test/lib/log4j-1.2.11.jar:/opt/te
> > st/lib/jms.jar:/opt/test/lib/sonic_Client.jar:/opt/test/lib/sonic_SF.jar
> > -Dlog4j.configuration=file:./log4j.properties test.MyLogger
> > mylogger.properties ./log4j.properties 1000
> > 
> > 
> > log4j.properties and mylogger,jar are in /opt/test, libraries are in
> > /opt/test/lib
> > 
> > 
> > Log4j.properties
> > ----------------
> > # Log4j parameters
> > log4j.rootLogger=console
> > delayLog4jFileChange = 20
> > 
> > # Set appenders for application classes
> > log4j.logger.MyLogger_application=INFO, APP_LOG, console
> > 
> > # Set appenders for messages
> > log4j.logger.test.MyLoggerThread=ALL, MSG_LOG, console
> > 
> > 
> > # Define parameters for log on the console
> > log4j.appender.console=org.apache.log4j.ConsoleAppender
> > log4j.appender.console.layout=org.apache.log4j.PatternLayout
> > log4j.appender.console.layout.ConversionPattern=[%d][%p (%F:%L)] %m%n
> > 
> > # Define parameters for the log on the file APP_LOG
> > log4j.appender.APP_LOG=org.apache.log4j.RollingFileAppender
> > log4j.appender.APP_LOG.File=./log/sciplogger.log
> > log4j.appender.APP_LOG.MaxFileSize=5000Kb
> > log4j.appender.APP_LOG.MaxBackupIndex=1
> > log4j.appender.APP_LOG.layout=org.apache.log4j.PatternLayout
> > log4j.appender.APP_LOG.layout.ConversionPattern=[%d] [%p (%F:%L)] %m%n
> > 
> > # Define parameters for the log on the file MSG_LOG
> > log4j.appender.MSG_LOG=org.apache.log4j.RollingFileAppender
> > log4j.appender.MSG_LOG.file=./log/SCIP_messages.log
> > log4j.appender.APP_LOG.MaxFileSize=5000Kb
> > log4j.appender.APP_LOG.MaxBackupIndex=1
> > log4j.appender.MSG_LOG.layout=org.apache.log4j.PatternLayout
> > log4j.appender.MSG_LOG.layout.ConversionPattern=%m%n
> > 
> > 
> > Application - Class MyLoggerThread.java (inside mylogger.jar)
> > -------------------------------------------------------------
> > 
> > ...
> > // Logger for application operation info
> > private static Logger applLogger =
> > Logger.getLogger("MyLogger_application");
> > 
> > // Logger for messages
> > private static Logger messageLogger =
> > Logger.getLogger(test.MyLoggerThread.class);
> > 
> > ...
> > ...
> > 
> > public synchronized void onMessage(Message message) {
> > 
> > ...
> > 
> > messageLogger.info(msg.toString()); // Doesn't log anything!
> > 
> > applLogger.debug("JMS message received: " + msg.toString());  // It
> > works!
> > 
> > ...
> > 
> > }
> > 
> > }
> > 
> > Rob
> > 
> > 
> > 
> > 
> > Gruppo Telecom Italia - Direzione e coordinamento di Telecom Italia S.p.A.
> > 
> > ====================================================================
> > CONFIDENTIALITY NOTICE
> > This message and its attachments are addressed solely to the persons
> > above and may contain confidential information. If you have received
> > the message in error, be informed that any use of the content hereof
> > is prohibited. Please return it immediately to the sender and delete
> > the message. Should you have any questions, please send an e_mail to
> > MailAdmin@tilab.com. Thank you
> > ====================================================================
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> > 
> > 
> 
> 
> --
> James Stauffer
> Are you good? Take the test at http://www.livingwaters.com/good/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 
> 
> Gruppo Telecom Italia - Direzione e coordinamento di Telecom Italia S.p.A.
> 
> ====================================================================
> CONFIDENTIALITY NOTICE
> This message and its attachments are addressed solely to the persons
> above and may contain confidential information. If you have received
> the message in error, be informed that any use of the content hereof
> is prohibited. Please return it immediately to the sender and delete
> the message. Should you have any questions, please send an e_mail to
> MailAdmin@tilab.com. Thank you
> ====================================================================
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 


--
James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic