logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: Using more than one logger
Date Mon, 02 Apr 2007 17:25:34 GMT

On Apr 2, 2007, at 11:28 AM, Rayapudi Sandeep-mgb376 wrote:

> Hi,
> I removed asterics and tested, but it doesnt seem to work.
> Config:
> -----------
> log4j.rootLogger=DEBUG
> log4j.logger.sysmonLogger=DEBUG, myappender
> log4j.additivity.sysmonLogger=false
> log4j.appender.myappender=org.apache.log4j.RollingFileAppender
> log4j.appender.myappender.File=../logs/sysmon.log
> log4j.appender.myappender.MaxFileSize=100KB
> log4j.appender.myappender.MaxBackupIndex=1
> log4j.appender.myappender.layout=org.apache.log4j.PatternLayout
> Program:
> ---------------
>                 PropertyConfigurator::configure(LOG4CXX_FILE 
> ("temp.properties"));
>                 LoggerPtr rootLogger = Logger::getRootLogger();
>                 LoggerPtr logger = Logger::getLogger("sysmonLogger");
>                 //LOG4CXX_INFO(logger,"info into R");
>                 LOG4CXX_INFO(logger, "info message");
>                 LOG4CXX_WARN(logger, "warn message");
>                 LOG4CXX_ERROR(logger, "error message");
> In above program, i tried both
> LoggerPtr logger = Logger::getLogger("sysmonLogger");  --> in this  
> case, it didnt print any error while debugging with gdb
> and
> LoggerPtr logger = Logger::getLogger("sysmon"); ---> this given  
> "log4cxx: No appender could be found for logger (sysmon)"
> Please help me out

That there is a different behavior for Logger::getLogger("sysmon")  
than for Logger::getLogger("sysmonLogger") suggests to me that your  
configuration file is being read and an appender is attached to  
"sysmonLogger", but it is not working as you expect.  Otherwise, I'd  
ask you to confirm that your configuration file is really named  

Your configuration file does specify use of a PatternLayout, but  
doesn't specify a conversion pattern, but that should default to the  
equivalent of:


To troubleshoot, I'd check the following:

Does the ../logs directory exist and does the current user have write  
privileges?  If the directory does not exist, log4cxx will not  
currently create it (may change in the future).

If ../logs/sysmon.log exists, does the current user have write  

What happens if you switch from org.apache.log4j.RollingFileAppender  
to org.apache.log4j.ConsoleAppender?  If you get console output, then  
I'd then try just a plain FileAppender before switching back to a  

You did not specify what version of log4cxx you are using or  
operating system that you are using.  Use of log4cxx-0.9.7 is no  
longer supported or recommended.

View raw message