How to configure Tomcat to log everything via syslog?

Philippe picture Philippe · Jul 27, 2010 · Viewed 15.1k times · Source

I'm trying to configure Tomcat and a webapp (Atlassian JIRA) to log everything over syslog.

Here is what I added to the webapp log4j.properties (atlassian-jira/WEB-INF/classes/log4j.properties) :

log4j.rootLogger=WARN, syslog
log4j.appender.syslog=org.apache.log4j.net.SyslogAppender
log4j.appender.syslog.facility=LOCAL0
log4j.appender.syslog.layout.ConversionPattern=%-5p [%t] [%c]: %m%n
log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
log4j.appender.syslog.SyslogHost=my.syslog.server.fqdn

However, nothing is sent over syslog. I sniffed outgoing packets on the port 514 and nothing appears.

Thanks for your help!

Answer

Philippe picture Philippe · Jul 28, 2010

Here is the solution I currently use :

  1. I removed the conf/logging.properties file
  2. I modified the atlassian-jira/WEB-INF/classes/log4j.properties in order to disable all file logging operations, leaving only console logging
  3. I modified catalina.sh in order to pipe its output to logger

I imagine this solution isn't java-world-compliant. But it's working.

However, I'm still looking for a cleaner way to log to syslog.