log4j的远程日志1 -- syslog
使用Log4j的SystemLogAppender可以实现远程的日志输出,为集中式的日志管理提供便利。
SystemLogAppender基于syslog服务。
1. 在CentOS5.4的日志服务器上,做如下配置,修改/etc/syslog.conf
local6.* /var/log/center.log
2. 启动Syslog服务
/etc/init.d/syslog stop ; /etc/init.d/syslog start
3. 在写日志的客户机上,修改log4j配置文件(替换${logServer}为你服务器的ip/hostname):
log4j.appender.syslog=org.apache.log4j.net.SyslogAppender log4j.appender.syslog.Facility=local6 log4j.appender.syslog.SyslogHost=${logServer} log4j.appender.syslog.FacilityPrinting=true log4j.appender.syslog.layout=org.apache.log4j.PatternLayout log4j.appender.syslog.layout.ConversionPattern=%5p %c{1} - %m%n
XML版本:
<appender name="syslog" class="org.apache.log4j.net.SyslogAppender"> <param name="SyslogHost" value="${logServer}"/> <param name="Facility" value="LOCAL6"/> <param name="FacilityPrinting" value="true"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%5p %c{1} - %m%n"/> </layout> </appender>
4. 更多关于syslog的参考:
http://www.precision-guesswork.com/sage-guide/syslog-overview.html
相关推荐
chw0 2020-11-04
sdaq 2020-07-26
MrLiar 2020-07-07
sdaq 2020-06-16
丨Fanny丨Cri 2020-06-13
CXC0 2020-06-08
MrLiar 2020-06-04
丨Fanny丨Cri 2020-06-03
丨Fanny丨Cri 2020-05-17
JavaWinner 2020-05-10
JavaWinner 2020-05-04
CXC0 2020-04-20
CXC0 2020-04-10
丨Fanny丨Cri 2020-02-18
MrLiar 2020-02-16
CXC0 2020-02-09