Individual log files using syslog
I am running Centos/Apache with PHP 5.5.14, and am using syslog to write to a log file as follows:
syslog(LOG_INFO,'Some message'); The logs are being written to /var/log/messages and look like "Aug 10 15:48:16 devserver httpd: Some message", however, the log file is also cluttered with a bunch of logs that look like "Aug 10 15:48:21 devserver kernel: usb 1-1.2: USB disconnect, device number 83". How do make PHP send logs to its own dedicated log file? Note that I don't think this is a PHP question, but a syslog question. I also don't wish to create my own PHP version log writer, but use syslog. Thanks |
I've been reading a bit about syslog. Evidently, the service can be started/stopped using /etc/init.d/syslog, but my server doesn't seem to have that service. Furthermore, it could be configured using /etc/syslog.conf, but I also don't have that file. It appears that Centos does it differently. Looks like I should use rsyslog, right?
The logs I care about all include httpd. For instance: Code:
Aug 10 15:48:16 devserver httpd: Some message |
Okay, maybe I have a solution. Edit rsyslog.conf and add the following.
Code:
local0.* /var/log/php.log Code:
*.info;mail.none;authpriv.none;cron.none;local0.none /var/log/messages I now log this way: Code:
openlog('myapplication', LOG_NDELAY, LOG_LOCAL0); |
All times are GMT -5. The time now is 05:17 PM. |