为什么 Syslog 没有将日志写入指定文件?

为什么 Syslog 没有将日志写入指定文件?

我一直在尝试通过 Syslog 路由 Apache 的日志(由于某种原因,日志轮换已经停止,使用 Syslog 和 logrotate 似乎是一个合理的解决方案)。

我已将 Apache 的错误日志发送到 local7,并通过记录器程序将访问日志传送到 local6。

我希望 Syslog 将错误和访问日志分别写入/var/log/apache2/error.log/var/log/apache2/access.log

为此,我添加了以下内容/etc/syslog.conf

# Logging for Apache using local7 facility for error messages
# and local6 for access log
# Added 20/06/2010 by Chris Bunney
local7.*                        /var/log/apache2/error.log
local6.*                        /var/log/apache2/access.log

我知道错误和访问日志被正确发送到 Syslog,因为它们显示在中/var/log/syslog,但它们并没有被写入我想要的文件中。

目标文件原文件权限:

-rw-r----- 1 root adm       0 2010-06-20 23:01 access.log

我一直在使用目标文件的当前文件权限来尝试排除导致问题的因素:

-rw-rw-rw- 1 syslog adm       0 2010-06-20 23:01 access.log

我觉得一切都很好,所以为什么 Syslog 接收的消息没有写入我想要的文件中?我是否遗漏了一些简单的事情?


完整输出cat /etc/syslog.conf

#  /etc/syslog.conf     Configuration file for syslogd.
#
#                       For more information see syslog.conf(5)
#                       manpage.

#
# First some standard logfiles.  Log by facility.
#

auth,authpriv.*                 /var/log/auth.log
*.*;auth,authpriv.none          -/var/log/syslog
cron.*                          /var/log/cron.log
daemon.*                        -/var/log/daemon.log
kern.*                          -/var/log/kern.log
lpr.*                           -/var/log/lpr.log
mail.*                          -/var/log/mail.log
user.*                          -/var/log/user.log

#
# Logging for the mail system.  Split it up so that
# it is easy to write scripts to parse these files.
#
mail.info                       -/var/log/mail.info
mail.warn                       -/var/log/mail.warn
mail.err                        /var/log/mail.err

# Logging for INN news system
#
news.crit                       /var/log/news/news.crit
news.err                        /var/log/news/news.err
news.notice                     -/var/log/news/news.notice

# Logging for Apache using local7 facility for error messages
# and local6 for access log
# Added 20/06/2010 by Chris Bunney
local7.*                        /var/log/apache2/error.log
local6.*                        /var/log/apache2/access.log

#
# Some `catch-all' logfiles.
#
*.=debug;\
        auth,authpriv.none;\
        news.none;mail.none     -/var/log/debug
*.=info;*.=notice;*.=warn;\
        auth,authpriv.none;\
        cron,daemon.none;\
        mail,news.none          -/var/log/messages

#
# Emergencies are sent to everybody logged in.
#
*.emerg                         *

#
# I like to have messages displayed on the console, but only on a virtual
# console I usually leave idle.
#
#daemon,mail.*;\
#       news.=crit;news.=err;news.=notice;\
#       *.=debug;*.=info;\
#       *.=notice;*.=warn       /dev/tty8

# The named pipe /dev/xconsole is for the `xconsole' utility.  To use it,
# you must invoke `xconsole' with the `-file' option:
#
#    $ xconsole -file /dev/xconsole [...]
#
# NOTE: adjust the list below, or you'll go crazy if you have a reasonably
#      busy site..
#
daemon.*;mail.*;\
        news.err;\
        *.=debug;*.=info;\
        *.=notice;*.=warn       |/dev/xconsole

答案1

你重启了 syslogd 吗?你还可以使用它lsof -f -p <pid-of-syslogd>来查看它打开了哪些日志文件。syslog.conf 看起来正确,你可能想要发布你的 apache 配置。

答案2

对于那些在从 Ubuntu LTS 12.04 更新到 14.04.1 后在谷歌上搜索类似症状的人来说:syslog 被 rsyslog 取代,由于某种原因,它没有通过发行版升级安装。

解决办法是apt-get install rsyslog

相关内容