Keshav
Keshav

Reputation: 4478

Tomcat6 webapp using log4j for logging, unable to log to syslog

I am trying to log my webapp logs into syslog at local4 level. Environment: Tomcat6, OpenSolaris, Struts2, log4j. Content of my log4j.properties is as follows-

log4j.rootLogger=INFO, SYSLOG
log4j.appender.SYSLOG=org.apache.log4j.net.SyslogAppender
log4j.appender.SYSLOG.syslogHost=localhost
log4j.appender.SYSLOG.layout=org.apache.log4j.PatternLayout
log4j.appender.SYSLOG.layout.ConversionPattern=%d [%t] %-5p - %m%n
log4j.appender.SYSLOG.Facility=local4

I have edited the /etc/syslog.conf and appended the following lines in the end-

local4.notice              /var/log/mylog.log

After this I have restarted the syslog service. When I run the following command from the shell it is logged in the /var/log/mylog.log properly. This mostly means that the syslog service is working correctly-

logger -i -p local4.notice -t "check  log" "test message"

But I am quite unable to understand why logs from the webapp never gets to the /var/log/mylog.log. Is my log4j configuration correct for the SysLogAppender?

When I try normal appenders like "DailyRollingFileAppender" etc., the logging works fine..but I am just unable to get the SyslogAppender to work..

Thanks! -Keshav

Upvotes: 3

Views: 3345

Answers (2)

gabe
gabe

Reputation: 1129

Similar issue on Ubuntu 10.04, I had to uncomment two lines in /etc/rsyslog.conf in order to receive SyslogAppender messages.

# provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514

Upvotes: 7

Ceki
Ceki

Reputation: 27490

Typically, appending to syslog fails because the syslog daemon is not set up to accept packets from the network. Your "logger -i -p" does not say if packets are allowed...

Upvotes: 2

Related Questions