LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-08-2014, 10:46 AM   #1
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 565

Rep: Reputation: Disabled
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
 
Old 11-08-2014, 11:52 AM   #2
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 565

Original Poster
Rep: Reputation: Disabled
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
Would I be able to just put those logs in a different log file?

Last edited by NotionCommotion; 11-08-2014 at 11:53 AM.
 
Old 11-08-2014, 12:25 PM   #3
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 565

Original Poster
Rep: Reputation: Disabled
Okay, maybe I have a solution. Edit rsyslog.conf and add the following.
Code:
local0.* /var/log/php.log
Note that I did NOT remove local0 from also going to /var/log/messages. For instance, I did not add the following:
Code:
*.info;mail.none;authpriv.none;cron.none;local0.none /var/log/messages
It is bad practice to allow messages to go to two logs?

I now log this way:
Code:
openlog('myapplication', LOG_NDELAY, LOG_LOCAL0);
syslog(LOG_INFO, "Log to myapplication LOG_LOCAL0");
I guess I am good, but if anything sticks out as being wrong, please advise.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] log files are empty -- messages,syslog,mail.err masuch Linux - General 7 02-26-2012 02:08 PM
Syslog-NG Format - Files or single log fcompagnari Linux - Newbie 1 08-15-2008 01:17 PM
syslog does not display empty log files Tom Douglas Linux - Server 3 05-03-2008 02:20 PM
howto network syslog with multiple log files mcalizo Red Hat 2 05-27-2005 07:58 AM
Syslog server can't open log files >500mb mikeyt_333 Linux - General 2 01-11-2005 12:32 PM


All times are GMT -5. The time now is 05:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration