简体   繁体   English

带有PHP和自定义文件的syslog

[英]syslog with PHP and a custom file

I'm trying to get a PHP command line script to write informational messages to a custom file. 我正在尝试获取一个PHP命令行脚本,以将参考消息写入自定义文件。 I'm working on a MacBook with OSX Lion installed. 我正在安装OSX Lion的MacBook上工作。 I (now) have this in my syslog.conf file: 我(现在)在syslog.conf文件中有此文件:

local2.error        /var/log/myapp/error.log
local2.=warning     /var/log/myapp/info.log
local2.=notice      /var/log/myapp/info.log
local2.=info        /var/log/myapp/info.log
local2.=debug       /var/log/myapp/info.log

And I have this in my PHP script: 我的PHP脚本中有这个:

openlog("myapp", LOG_NDELAY, LOG_LOCAL2);
syslog(LOG_INFO, 'Testing informational messages with PHP');
closelog();

When I run the script, nothing is logged in /var/log/myapp/info.log, but (I think) it should be. 当我运行脚本时,/ var / log / myapp / info.log中没有任何记录,但是(我认为)应该如此。

Thanks, 谢谢,

Troy 特洛伊

local2.!err means all level except error level will be written to the file, not below. local2。!err表示除错误级别外的所有级别都将写入文件,而不是下面的级别。

local2.=err means only error level will be written. local2。= err表示将仅写入错误级别。

local2.err means level is equal to or greater than error will be written. local2.err表示将写入等于或大于错误的级别。

local2.* means all level will be written. local2。*表示将写入所有级别。

In your question, you code 在您的问题中,您编写代码

syslog(LOG_INFO, 'Testing informational messages with PHP');

take effect when using local2.err but it shouldn't. 在使用local2.errlocal2.err但不应生效。 Did you restart the syslogd after change the conf? 更改conf后是否重新启动syslogd?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM