简体   繁体   中英

log4j syslog remote server

I'm using spring and log4j and I want to use the SyslogAppender. This is my configuration:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="true"
    xmlns:log4j='http://jakarta.apache.org/log4j/'>

    <appender name="syslog" class="org.apache.log4j.net.SyslogAppender">
        <param name="Facility" value="LOCAL7" />
         <param name="FacilityPrinting" value="true"/>
        <param name="SyslogHost" value="xx.xx.xxx.xx" />
        <param name="Threshold" value="INFO" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{MMM dd HH:mm:ss} MYAPP: %-5p %m%n" />
        </layout>
    </appender>



    <root>
        <level value="INFO" />
        <appender-ref ref="syslog" />
    </root>


</log4j:configuration>

But when I look at the syslog server it shows nothings, no file is created. I know the syslog server works cause I tried in from a different server. Tried adding the syslog port but it didn't work

<param name="SyslogHost" value="xx.xx.xxx.xx:514" />

Check if your syslog is accepting logs from a remote host. Syslog usually listens on 514 port (TCP or UDP). Remote logging is disabled by default on most distributions.

Check:

netstat -utn | grep :514

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM