我正在尝试设置我的 ec2 实例(运行 amazon linux,据我所知,它是建立在 RHEL 5 上的)将日志消息转发到 loggentries.com,但没有任何内容被转发。作为健全性检查,我按照本文中的说明将另一个 EC2 实例设置为中央服务器,发现没有收到消息。所以我尝试logger -p cron.info TEST
在客户端机器上执行,发现/var/log/cron 中没有添加任何内容!显然有些东西不起作用!但是 rsyslogd 正在运行:
ps 辅助 | grep rsys
产出
根 25362 0.0 0.0 183768 1328 ?Sl 14:27 0:00 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5
作为参考,这里是 rsyslog.conf(暂时删除了转发内容,直到我让它在本地工作)
#### MODULES ####
$ModLoad imuxsock.so # provides support for local system logging (e.g. via logger command)
$ModLoad imklog.so # provides kernel logging support (previously done by rklogd)
#$ModLoad immark.so # provides --MARK-- message capability
# Provides UDP syslog reception
#$ModLoad imudp.so
#$UDPServerRun 514
# Provides TCP syslog reception
#$ModLoad imtcp.so
#$InputTCPServerRun 514
#### GLOBAL DIRECTIVES ####
# Use default timestamp format
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
# File syncing capability is disabled by default. This feature is usually not required,
# not useful and an extreme performance hit
#$ActionFileEnableSync on
#### RULES ####
# Log all kernel messages to the console.
# Logging much else clutters up the screen.
kern.* /dev/console
# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none /var/log/messages
# The authpriv file has restricted access.
authpriv.* /var/log/secure
# Log all the mail messages in one place.
mail.* -/var/log/maillog
# Log cron stuff
cron.* /var/log/cron
# Everybody gets emergency messages
*.emerg *
# Save news errors of level crit and higher in a special file.
uucp,news.crit /var/log/spooler
# Save boot messages also to boot.log
local7.* /var/log/boot.log
您唯一需要
rsyslog.conf
转发到远程 IP 地址的是关于你的另一个问题...
确保在更改配置后重新启动 rsyslogd;您还需要确保它
/var/log/cron
存在。编辑
为了演示成功的日志条目是什么样的,我
rsyslogd
从rsyslogd -c4 -d
; 这会将所有调试发送到我的 ssh 会话。我登录cron.info
到/var/log/syslog
. 在另一个 ssh 会话中,我运行了logger -p cron.info "my test again"
……这是我在成功登录之前看到的/var/log/syslog
……