views:

638

answers:

2

Hello,

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

A: 

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...

Ceki
Sorry, I did not understand. I am trying from localhost and I am certain that the syslogd is listening on its udp port.
Keshav
Thanks Ceki, you had given me the right advice.
Keshav
+1  A: 

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
gabe