ken
ken

Reputation: 9013

Controlling the error log's text

I am sending in error log information using PHP's error_log() function and it's working just fine except that every line -- when run from the web-browser under MAMP -- is prepending a timestamp such as this:

[26-Jun-2013 00:29:23 Europe/London] My message goes here

Obviously a timestamp isn't the worst idea but I'd like to have control over the full text and how and where the timestamp goes on the line. How does this initial text get set? I thought it must be in the php.ini or httpd.ini files but on quick perusal I couldn't find it.

Upvotes: 0

Views: 413

Answers (2)

Amal Murali
Amal Murali

Reputation: 76656

Create your own error handler: http://php.net/manual/en/function.set-error-handler.php It works with trigger_error()

If you're running Apache it appears this may be something controlled by mod_log_config. There is a LogFormat directive in your httpd.conf that controls the format for error messages

Similar thread: How to change default timestamp that PHP uses for logging to file?

Upvotes: 2

Mark Basmayor
Mark Basmayor

Reputation: 2569

You can't, at least not in Apache 2.

It is not possible to customize the error log by adding or removing information. However, error log entries dealing with particular requests have corresponding entries in the access log. For example, the above example entry corresponds to an access log entry with status code 403. Since it is possible to customize the access log, you can obtain more information about error conditions using that log file.

http://httpd.apache.org/docs/2.2/logs.html#errorlog

So if you want a custom formatted log, don't use apache's error log.

Upvotes: 2

Related Questions