将log4j输出到rsyslog服务器
November 9th, 2011
Leave a comment
Go to comments
Leave a comment
Go to comments
开通 rsyslog 远程 UDP 访问
vim /etc/rsyslog.conf
去掉下面两行前的注释
#$ModLoad imudp #$UDPServerRun 514
并在文件的最后,加入
local9.info /var/log/local9_info.log local9.debug /var/log/local9_debug.log
修改完后,重启 rsyslog
/etc/init.d/rsyslog restart
log4j 配置
log4j.rootLogger=debug, syslog log4j.appender.syslog=org.apache.log4j.net.SyslogAppender log4j.appender.syslog.Threshold=DEBUG log4j.appender.syslog.layout=org.apache.log4j.PatternLayout log4j.appender.syslog.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n log4j.appender.syslog.Header=true # 打印时附加发送的机器名称 log4j.appender.syslog.Facility=local9