0

I'm trying to get a PHP command line script to write informational messages to a custom file. I'm working on a MacBook with OSX Lion installed. I (now) have this in my syslog.conf file:

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:

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.

Thanks,

Troy

Troy
  • 1,799
  • 3
  • 20
  • 29

1 Answers1

0

local2.!err means all level except error level will be written to the file, not below.

local2.=err means only error level will be written.

local2.err means level is equal to or greater than error will be written.

local2.* means all level will be written.

In your question, you code

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

take effect when using local2.err but it shouldn't. Did you restart the syslogd after change the conf?

kimjxie
  • 641
  • 7
  • 11
  • I'm on a macbook and I was restarting using launchctl. syslogd spiked cpu usage after a couple of restarts, so I resorted to rebooting. The restart I needed might have been lost in there somewhere. I edited my syslog.conf file after reading your post and rebooted, but it's still not logging anything. I updated my post with the new code. Any suggestions? – Troy Jul 17 '12 at 08:11