Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

log4j telnet appender, example needed 1

Status
Not open for further replies.

hDepotRacing20

Programmer
Feb 14, 2006
3
US
Im trying to figure out how to use the telnet appender. Very little documentation on and have found no working examples to show its use. Anyone know how to use the telnet appender and be willing to give a short example of using in log4j properties file.. Thnx
 
It is configured just like any other appender with the addition of being able to specify a port (which defaults to 23 - the standard Telnet port)

For example, I set this up in my log4j.properties file
Code:
log4j.rootLogger=DEBUG, Remote

# Remote Telnet Appender
log4j.appender.Remote=org.apache.log4j.net.TelnetAppender
log4j.appender.Remote.port=23
log4j.appender.Remote.layout=org.apache.log4j.PatternLayout
log4j.appender.Remote.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

I then started my application which writes to this logger, and was then able to open a separate command window and type
Code:
telnet localhost

Logging output began to appear in the telnet session. Well cool.

Obviously, if the application is running on a machine which already has a Telnet server on port 23 or you don't have security rights for Log4j to create a socket on port 23, then you'd need to use a different port.

Hope this helps.

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top