Closed zachkinstner closed 11 years ago
Logging for the console has additional complexity, because there are many outputs that should go directly to System.out
or System.err
. The solution was to add the SessionContext.logAndPrint
method, which sends output to both Log4j and System.
Sample log4j.console.properties
file:
log4j.rootLogger=ALL, rcc
log4j.appender.rcc=org.apache.log4j.RollingFileAppender
log4j.appender.rcc.File=logs/RexConnectConsole.log
log4j.appender.rcc.MaxFileSize=10MB
log4j.appender.rcc.MaxBackupIndex=5
log4j.appender.rcc.Append=true
log4j.appender.rcc.layout=org.apache.log4j.PatternLayout
log4j.appender.rcc.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%p] %C{1} - %m%n
Sample log4j.server.properties
file:
log4j.rootLogger=ALL, stdout, rcs
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%p] %C{1} - %m%n
log4j.appender.rcs=org.apache.log4j.RollingFileAppender
log4j.appender.rcs.File=logs/RexConnectServer.log
log4j.appender.rcs.MaxFileSize=10MB
log4j.appender.rcs.MaxBackupIndex=5
log4j.appender.rcs.Append=true
log4j.appender.rcs.layout=org.apache.log4j.PatternLayout
log4j.appender.rcs.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%p] %C{1} - %m%n
RexConnect should have some actual logging capability, instead of just printing everything to
System.out
. Refer to the Rexster Application class for a real-world example.