使用以下rsyslog配置:
我的输出总是在记录的消息(在自定义日志文件中)之前有一个空格。
$template MYFORMAT,"%msg%\n"
if $programname == 'mylog' then {
action(type="omfile" file="/var/log/mylog.log" template="MYFORMAT")
& stop
}
以及这段 PHP 脚本:
<?php
openlog('mylog', LOG_ODELAY, LOG_LOCAL0);
syslog(LOG_INFO, date('Y-m-d: ') . 'stuff has happened!');
closelog();
我的输出总是在记录的消息(在自定义日志文件中)之前有一个空格。
2015-06-10: stuff has happened! (there's a space at the beginning of this line)