How would I dynamically turn log4cxx logging to the console on and off in an 
application?

Goal here is to process a used choice, command line parm or GUI input or 
whatever. Thus in a hypothetical main loop:

if ( userWantsToStartConsoleLogger )
    ConsoleLogger( true );
if ( userWantsToStopConsoleLogger )
    ConsoleLogger( false );

My logging setup is:

#include <log4cxx/logger.h>
#include <log4cxx/propertyconfigurator.h>
#include <log4cxx/helpers/exception.h>

int main( int argc, char** argv )
{
   const log4cxx::LoggerPtr   logger;
   log4cxx::PropertyConfigurator::configure("./logs.config");
}

where ./logs.config looks like:

log4j.rootLogger=INFO, File

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n

log4j.appender.File=org.apache.log4j.RollingFileAppender
log4j.appender.File.File=logs/system.logs
log4j.appender.File.MaxFileSize=1MB
log4j.appender.File.MaxBackupIndex=10
log4j.appender.File.layout=org.apache.log4j.PatternLayout
log4j.appender.File.layout.ConversionPattern=%d{MM/dd/yyyy HH:mm:ss:SSS a}  %p  
%c  %m%n

NOTE: Presently, I have to add , stdout after FILE in the rootlogger= line to 
accomplish this.

In this context, of course, the question is, what goes in my ConsoleLogger() 
function?

Thanks,

Wea


________________________________
CONFIDENTIALITY NOTE:

This e-mail and any attachments are confidential. If you are not the intended 
recipient, be aware that any disclosure, copying, distribution or use of this 
e-mail or any attachment is prohibited. If you have received this e-mail in 
error, please notify us immediately by returning it to the sender and delete 
this copy from your system. Thank you for your cooperation.

Reply via email to