r5 - 19 Jul 2007 - 06:24:03 - MimiYinYou are here: OSAF >  Journal Web  >  QualityAssuranceTeam > AdamChristianNotes > AdamChristianlog4jTelnet

Configuring tomcat and log4j to output to the telnetAppender

Currently the bundle is using a file called log4j.xml which is located in /osaf-server-bundle-version/tomcat/common/classes
Everything I tried in terms of using the telnetAppender gave me an error message having to do with its inability to bind to the port so the solution I came up with was the following.

Delete the log4j.xml file, replace it with a log4j.properties file with the following contents:

File: /osaf-server-bundle-version/tomcat/common/classes/log4j.properties
-----------------------------------------------------------------

#######################################################################
# Categories and levels
#######################################################################

log4j.rootCategory=DEBUG, Telnet

#######################################################################
# Appenders
#######################################################################

# FileApp is set to be a RollingFileAppender
 #log4j.appender.FileApp=org.apache.log4j.RollingFileAppender
 #log4j.appender.FileApp.File=logs/osafsrv.log
 #log4j.appender.FileApp.MaxFileSize=1000KB
 #log4j.appender.FileApp.BufferedIO=false

# Keep one backup file
 #log4j.appender.FileApp.MaxBackupIndex=1
 #log4j.appender.FileApp.layout=org.apache.log4j.PatternLayout
 #log4j.appender.FileApp.layout.ConversionPattern=%d [%t] %-5p %c{1} - %m%n

# Telnet is a socket hub appender
 log4j.appender.Telnet=org.apache.log4j.net.TelnetAppender
 log4j.appender.Telnet.layout=org.apache.log4j.PatternLayout
#log4j.appender.Telnet.layout.ConversionPattern=[cc]%d{MMM-dd HH:mm:ss} %-14.14c{1}- %m%n
 log4j.appender.Telnet.layout.ConversionPattern=%d #%# {ISO8601} #%#  %-5p #%#  [%c{1}] #%#  %m%n
 log4j.appender.Telnet.port=9005

Then you can go ahead and connect to the box where this is running on port 9005 and witness the magic.

Another great page for configuration directions is: http://logging.apache.org/log4j/docs/api/org/apache/log4j/PropertyConfigurator.html

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r5 < r4 < r3 < r2 < r1 | More topic actions
 
Open Source Applications Foundation
Except where otherwise noted, this site and its content are licensed by OSAF under an Creative Commons License, Attribution Only 3.0.
See list of page contributors for attributions.