Problem reporting event to Syslog with Log4j

Did anybody tried this ?

I have configured the Log4j to write to Syslog. Syslog service is up and running, but nothing is printed into syslog.

Here is my log4j.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

<appender name="syslog" class="org.apache.log4j.net.SyslogAppender">
     <param name="SyslogHost" value="127.0.0.1"/>
     <param name="Facility" value="USER"/>
    <param name="Threshold" value="INFO"/>
     <param name="FacilityPrinting" value="true"/>
     <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%t %5r %-5p %-21d{yyyyMMdd [HH]mm:ss,SSS} %c{2} [%x] %m %n"/>
     </layout>
</appender>
 
  <appender name="console" class="org.apache.log4j.ConsoleAppender">
    <param name="Target" value="System.out"/>
    <param name="Threshold" value="INFO"/>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%-5p %t %c{1} - %m%n"/>
    </layout>
  </appender>

  <logger name="com.clearforest">
    <level value="INFO"/>
    <appender-ref ref="syslog" />
    <appender-ref ref="console" />
  </logger>

  <root>
    <level value="info"/>
    <appender-ref ref="syslog" />
  </root>
</log4j:configuration>

Comments

Your facility is wrong. Facility should be a number such as (see org.apache.log4j.net.SyslogAppender):

public static final int LOG_LOCAL0 = 128;
public static final int LOG_LOCAL1 = 136;
public static final int LOG_LOCAL2 = 144;
public static final int LOG_LOCAL3 = 152;
public static final int LOG_LOCAL4 = 160;
public static final int LOG_LOCAL5 = 168;
public static final int LOG_LOCAL6 = 176;
public static final int LOG_LOCAL7 = 184;

In addition make sure:

1) Modify the /etc/syslog.conf file by adding the following line of text:

#Tigor log
local6.* /home/tigor/log.log

2) Your syslog daemon must be started with remote logging enabled (the -r command line option).
Restart the daemeon.
ps -ef | grep syslog
/sbin/syslogd -r -u syslog

3) To test the logger from the linux command line type> logger -p local6.debug "this is a test"

have fun