如何解决NXLog - 每小时日志轮换
目标:NXlog 接收大数据源。需要它每小时轮换文件,以便压缩。
我希望文件名表示时间范围,并存储在也表示时间范围的文件夹中。
示例:/fileshare/logsource/$year/$month/$day/log_$year_$date_$month_$hour.log
我在这里走的是正确的道路吗?我可以以任何方式简化它吗?
到目前为止的配置:
########################################
# Global directives #
########################################
User nxlog
Group nxlog
LogFile /var/log/nxlog/nxlog.log
LogLevel INFO
########################################
# Modules #
########################################
<Extension _syslog>
Module xm_syslog
</Extension>
<Extension _fileop>
Module om_file
Exec log_info()
<Input in1>
Module im_udp
Port 514
Exec parse_syslog_bsd();
</Input>
<Output fileout>
Module om_file
File "/fileshare/" + strftime(now(),"%Y") + "/" + strftime(now(),"%m") + "/" + strftime(now(),"%d") + "/log_" + strftime(now(),"%Y_%m_%d_%H) + ".log"
<Schedule>
When "0 * * * *"
<Exec>
$newfile = "/fileshare/" + strftime(now(),"%Y_%m_%d_%H) + ".log";
file->rotate_to($newfile);
exec_async("/bin/gzip",$newfile);
</Exec>
</Schedule>
Exec to_syslog_bsd();
</Output>
########################################
# Routes #
########################################
<Route 1>
Path in1 => fileout1
</Route>
任何帮助将不胜感激!谢谢。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。