[英]Basic rsyslog configuration
I have program logging to Syslog and I want to split those messages out into separate files. 我将程序日志记录到Syslog,我想将这些消息拆分为单独的文件。
I want all messages generated by MyApp
to go to /var/log/my_app.log
, and anything warn
or more serious to also go to /var/log/my_app.err
. 我希望MyApp
生成的所有消息都转到/var/log/my_app.log
,任何warn
或更严重的消息也都转到/var/log/my_app.err
。
I don't want the messages to end up in /var/log/syslog
, as they do at the moment. 我不希望消息像现在一样以/var/log/syslog
结尾。
I have created a new rsyslog conf file /etc/rsyslog.d/10-my_app.conf
in which I have: 我创建了一个新的rsyslog conf文件/etc/rsyslog.d/10-my_app.conf
,其中:
if $programname == 'MyApp'
then
{
if $pri <= 4
then
{
/var/log/my_app.err
}
/var/log/my_app.log
& stop
}
But it's only partially working. 但这只是部分工作。 All messages end up in my_app.log
, half of the messages still appear in syslog
& nothing appears in my_app.err
所有消息my_app.log
,其中一半消息仍显示在syslog
中,而my_app.err
中my_app.err
显示任何my_app.err
I found a solution: 我找到了解决方案:
if $programname == 'MyApp'
then
{
*.warning /var/log/my_app.err
*.* /var/log/my_app.log
& stop
}
Half of the problem was that my config file was getting loaded after another file which was logging my lines to /var/log/syslog
before I had a chance to drop them, so I needed to change some file names to fix that. 问题的一半是我的配置文件被加载到另一个文件之后,该文件将我的行记录到/var/log/syslog
然后才有机会删除它们,因此我需要更改一些文件名来解决此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.