如何在Apache CustomLog指令中使用时间戳
我希望Apache服务器在日志文件名中使用时间戳 我希望每小时创建一个日志文件,如下所示:如何在Apache CustomLog指令中使用时间戳,apache,logging,Apache,Logging,我希望Apache服务器在日志文件名中使用时间戳 我希望每小时创建一个日志文件,如下所示: application.log.2018-01-01-15 application.log.2018-01-01-16 application.log.2018-01-01-17 application.log.2018-01-01-18 CustomLog "/var/log/apache2/healthd/application.log.%{%Y-%m-%d-%H}t" healthd 我尝试过使
application.log.2018-01-01-15
application.log.2018-01-01-16
application.log.2018-01-01-17
application.log.2018-01-01-18
CustomLog "/var/log/apache2/healthd/application.log.%{%Y-%m-%d-%H}t" healthd
我尝试过使用CustomLog指令,如下所示:
application.log.2018-01-01-15
application.log.2018-01-01-16
application.log.2018-01-01-17
application.log.2018-01-01-18
CustomLog "/var/log/apache2/healthd/application.log.%{%Y-%m-%d-%H}t" healthd
但它会创建具有此文字名称的文件。不使用时间戳替换结尾
实现这一点的正确方法是什么?解决方案是使用Apache rotatelogs 它可以与Debian上的apt get install apache2 utils一起安装 必须将Apache配置为使用它:
CustomLog "|/usr/bin/rotatelogs -l /var/log/apache2/healthd/application.log.%Y-%m-%d-%H 3600" logformat