Using Syslog's unix socket with Log4J2

情到浓时终转凉″ 提交于 2019-12-05 20:31:20

问题


I would like to send the logs of an application on a rsyslog server using the client protocol : Unix socket. Both application and rsyslog server are on the same machine.

I've been comparing different logging tools : Log4J, Logback and Log4J2.

Log4J's Syslog appender doesn't permit it natively. A solution is to use Syslog4J and configure our Syslog4JAppender this way :

<appender name="mySyslogAppender" class="org.productivity.java.syslog4j.impl.log4j.Syslog4jAppender">
    <param name="protocol" value="unix_socket" />
    ...
</appender>

Same as Log4J, Logback's Syslog appender doesn't permit it natively. A solution is to use Syslog4J and logback-syslog4j tool, and configure our appender this way :

<appender name="mySyslogAppender" class="com.papertrailapp.logback.Syslog4jAppender">
    <syslogConfig class="org.productivity.java.syslog4j.impl.unix.socket.UnixSocketSyslogConfig">
            ...
    </syslogConfig>
</appender>

Now I'm looking for a solution for Log4J 2, but I didn't find any. Do you know one ? Do these tools will include natively this functionality ?

来源:https://stackoverflow.com/questions/32053768/using-syslogs-unix-socket-with-log4j2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!