问题描述
我有一个使用log4j SyslogAppender(facility = USER)的java应用程序,我可以看到在端口514上使用tcpdump,我的应用程序正在发送预期的日志消息作为数据报,netstat也告诉我syslogd(red hat)正在运行,在0.0.0.0:514上收听,但我没有在/ var / log / messages中看到任何日志记录。
I have a java application using log4j SyslogAppender (facility=USER) and I can see using tcpdump on port 514 that my application is sending intended log message as a datagram and also netstat shows me that syslogd (red hat) is running and listening on 0.0.0.0:514 but I do not see any logging happening in /var/log/messages.
在我的syslog.conf中,我有
In my syslog.conf, I have
*.info /var/log/messages
我对SyslogAppender的转换模式是
My conversion pattern for SyslogAppender is
%d{MMM dd HH:mm:ss} %F %L %5p [%t] %m %n"
我无法理解为什么它没有记录或我应该在哪里找到什么是失败的。我没有足够的机器上的权限,用于启动/停止syslogd或手动运行以启用详细的调试日志。
I am clueless as why it is failing to log or where exactly should I look for to see what is failing. And I don't have enough permissions on the machine to start/stop syslogd or run manually to have verbose debug logs enabled.
有关如何继续的任何指示?
Any pointers as how I proceed?
编辑:
下面的Appender
The Appender below
private void initSyslog() {
SyslogAppender syslogAppender = new SyslogAppender();
syslogAppender.setName("syslog");
syslogAppender.setLayout(new PatternLayout("%d{MMM dd HH:mm:ss} %F %L %5p [%t] %m %n"));
syslogAppender.setFacility("USER");
syslogAppender.setFacilityPrinting(true);
syslogAppender.setSyslogHost("localhost");
syslogAppender.activateOptions();
Logger.getRootLogger().addAppender(syslogAppender);
Logger.getRootLogger.info("Syslogdone");
}
推荐答案
未启用远程日志记录系统日志。很奇怪,因为它仍然打开并监听514.一旦我开始使用syslog -r,一切都开始记录。
Remote logging was not enabled in syslog. Weird, because it still opens and listens on 514. Once I started with syslog -r, everything started logging.
这篇关于Log4j和syslogappender的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!