Log4j输出格式设置参数:
http://avaj.iteye.com/blog/246088
配置Syslog
# This is the configuring for logging displayed in the Application Server
log4j.rootCategory=INFO,stdout,logfile,syslog
#stdout configure
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern= %d %p [%c:%L] - <%m>%n
#syslog configure
log4j.appender.syslog=org.apache.log4j.net.SyslogAppender
log4j.appender.syslog.SyslogHost=127.0.0.1
log4j.appender.syslog.Facility=LOCAL4
log4j.appender.syslog.Threshold=INFO
log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
#log4j.appender.syslog.layout.ConversionPattern= ac-web: [%C:%M] <%-5p> (%L) - %m%n
log4j.appender.syslog.layout.ConversionPattern= ac-web: [%C{1}] <%-5p> %m%n
#logfile configure
log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.File=/usr/local/ac/web/ac-web/logs/ac-web.log
log4j.appender.logfile.MaxFileSize=3000KB
log4j.appender.logfile.MaxBackupIndex=10
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern= %d %p [%c] - <%m>%n
如果仅设置了上面的内容也不会将日志通过Syslog的方式打印,还需要做下面的一些操作:
Stop syslog service - /etc/rc.d/init.d/syslog stop
Start syslog service - /sbin/syslogd -r [此处的参数-r是确保我们需要使用的514端口已经打开。默认情况下系统是不会打开514端口的。]