【RSYSLOG】Log4x To Rsyslog Config

Log4x To Rsyslog Config

Log4net配置

<!--RemoteSyslogAppender-->
<appender name="remoteSyslogAppender" type="log4net.Appender.RemoteSyslogAppender">
      <facility value="local0" />
      <identity value="%date{yyyy-MM-ddTHH:mm:ss.ffffffzzz} %P{log4net:HostName} 填写系统缩写(双引号前请保留一个空格) " />
      <RemoteAddress value="rsyslog-ip" />
      <RemotePort value="rsyslog-port" />
      <Encoding value ="UTF-8" />
      <layout type="log4net.Layout.PatternLayout" value="%d [%-5p] [%t] - %m%n"/>
</appender>

<!--ref appender to logger 以下仅供参考 appender-ref可以多个-->
 <logger name="ERRORlogger" additivity="false">
     <level value="ERROR"/>
     <appender-ref ref="remoteSyslogAppender"/>
 </logger>

Log4j配置

Log4j暂时不支持sys-tag配置

#appender rsyslog
log4j.appender.rsyslog=org.apache.log4j.net.SyslogAppender
log4j.appender.rsyslog.syslogHost=rsyslog-ip
log4j.appender.rsyslog.Facility=local1
log4j.appender.rsyslog.FacilityPrinting=true
log4j.appender.rsyslog.header=true
log4j.appender.rsyslog.layout=org.apache.log4j.PatternLayout
log4j.appender.rsyslog.layout.conversionPattern=%d [%-5p] [%t] - %m%n
posted @ 2017-04-18 23:09  曾逸群  阅读(277)  评论(0编辑  收藏  举报