如何配置 Tomcat 通过 syslog 记录所有内容?
我正在尝试配置 Tomcat 和 web 应用程序(Atlassian JIRA)以通过 syslog 记录所有内容。
以下是我添加到 web 应用程序 log4j.properties (atlassian-jira/WEB-INF/classes/log4j.properties) 中的内容:
log4j.rootLogger=WARN, syslog
log4j.appender.syslog=org.apache.log4j.net.SyslogAppender
log4j.appender.syslog.facility=LOCAL0
log4j.appender.syslog.layout.ConversionPattern=%-5p [%t] [%c]: %m%n
log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
log4j.appender.syslog.SyslogHost=my.syslog.server.fqdn
但是,没有通过 syslog 发送任何内容。我嗅探了端口 514 上的传出数据包,但没有出现任何内容。
感谢您的帮助!
I'm trying to configure Tomcat and a webapp (Atlassian JIRA) to log everything over syslog.
Here is what I added to the webapp log4j.properties (atlassian-jira/WEB-INF/classes/log4j.properties) :
log4j.rootLogger=WARN, syslog
log4j.appender.syslog=org.apache.log4j.net.SyslogAppender
log4j.appender.syslog.facility=LOCAL0
log4j.appender.syslog.layout.ConversionPattern=%-5p [%t] [%c]: %m%n
log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
log4j.appender.syslog.SyslogHost=my.syslog.server.fqdn
However, nothing is sent over syslog. I sniffed outgoing packets on the port 514 and nothing appears.
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是我当前使用的解决方案:
我想此解决方案不符合 java-world 标准。但它正在发挥作用。
但是,我仍在寻找一种更清晰的方式来记录系统日志。
Here is the solution I currently use :
I imagine this solution isn't java-world-compliant. But it's working.
However, I'm still looking for a cleaner way to log to syslog.
我还非常想要 JIRA 的系统日志附加程序,它不需要单独的记录器进程。
修改了/opt/jira/atlassian-jira/WEB-INF/classes/log4j.properties,如Q中所示,相关结果如下:
我可能是错的,但它看起来像org.apache.log4j.helpers .Loader.loadClass 类加载器知道 org.apache.log4j 包,但 不知道 org.apache.log4j.net 包,即使它们驻留在同一个包中jar /opt/jira/lib/log4j-1.2.15.jar。
在撰写本文时:JIRA 4.4.1 通过 Linux 64 位安装程序。
I also would really like a syslog appender for JIRA that doesn't require a separate logger process.
Modified /opt/jira/atlassian-jira/WEB-INF/classes/log4j.properties as indicated in the Q with relevant result as follows:
I could be wrong, but it looks like the org.apache.log4j.helpers.Loader.loadClass class loader knows about the org.apache.log4j package but NOT org.apache.log4j.net package even though they reside in the same jar /opt/jira/lib/log4j-1.2.15.jar.
At time of writing: JIRA 4.4.1 via Linux 64-bit Installer.
对于访问日志:https://github.com/magwas/SyslogValve
由于使用的 api 不断变化,因此可能需要针对您的 tomcat 版本进行调整。
For access logs: https://github.com/magwas/SyslogValve
It might needs tweaking for your tomcat version through, as the used api is constantly changing.