我用来rsyslog
将系统日志条目从一堆服务器转发到洛格利
配置看起来是这样的:
# Config for loggly upload
*.* @@logs.loggly.com:12345
这是可行的,但是因为它是转发,所以在没有互联网连接时发生的任何日志条目都不会出现在 loggly 中。
有什么办法可以配置 rsyslog 来“保留”日志条目,直到建立互联网连接,然后再发送它们吗?或者我应该使用其他工具来实现这一点?
答案1
如果无法连接远程服务器,Rsyslog 能够将消息缓冲到磁盘。 rsyslog.conf
我的 Fedora 系统上的默认设置包括以下示例:
# ### begin forwarding rule ###
# The statement between the begin ... end define a SINGLE forwarding
# rule. They belong together, do NOT split them. If you create multiple
# forwarding rules, duplicate the whole block!
# Remote Logging (we use TCP for reliable delivery)
#
# An on-disk queue is created for this action. If the remote host is
# down, messages are spooled to disk and sent when it is up again.
#$WorkDirectory /var/lib/rsyslog # where to place spool files
#$ActionQueueFileName fwdRule1 # unique name prefix for spool files
#$ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible)
#$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
#$ActionQueueType LinkedList # run asynchronously
#$ActionResumeRetryCount -1 # infinite retries if host is down
# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional
#*.* @@remote-host:514
#
### end of the forwarding rule ###
配置详细说明这个文件。
答案2
系统日志工具如果无法将日志发送到服务器,则可以将日志缓冲到磁盘。
destination d_tcp { tcp(“logserver” log_disk_fifo_size(100000000)); };