Sergey Stolyarov
Sergey Stolyarov

Reputation: 2657

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

In the php.ini:

error_log = php_errors.log

So all error_log() calls go into the file php_errors.log, every line is prepended by timestamp like [17-Jan-2012 18:05:04].

Is it possible to modify that timestamp? I need to display milli/microseconds as well as seconds and don't know how to do that using standard config options.

Upvotes: 3

Views: 2794

Answers (3)

Charles Sprayberry
Charles Sprayberry

Reputation: 7853

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. However, looking through the docs on strftime() it doesn't appear that milliseconds are possible.

I would likely just roll-my-own error handler that controls the timestamp more directly using date()

Upvotes: 0

i-CONICA
i-CONICA

Reputation: 2379

I can't think of a way to prepend by your milisecond / microseconds, but you could append it in option 3 of error_log() in the message parameter.

Upvotes: 0

Mārtiņš Briedis
Mārtiņš Briedis

Reputation: 17762

Create your own error handler: http://php.net/manual/en/function.set-error-handler.php

Upvotes: 2

Related Questions