Fiti
Fiti

Reputation: 199

How can I separate php log by date?

Here is my actual configuration vhost conf on each of my domains :

<VirtualHost *:80>
   ...
   php_value error_log /var/log/php-logs/domainName/error.log
   ...
</VirtualHost>

What can I do to keep this path (one directory by domain) but to split the php logs by day (20131218.log, 20131219.log, etc. instead of error.log) ?

Upvotes: 1

Views: 1177

Answers (1)

symcbean
symcbean

Reputation: 48367

Wrikken (see comments) suggests simply using logrotate - but in order for this to work, you need to close and reopen every file handle referencing the log - if you are using a Linux distribution with logrotate already configured for Apache and PHP is invoked via mod_php and you don't mind the interruption to the service, then you just need to add this file to the logs rotated for Apache. But this becomes very messy if you want to keep your server up or you are using php-fpm. But you didn't tell us about the webserver, the operating system or the SAPI version.

Other solutions

  • (on Linux/Unix/BSD) use the system logging daemon (error_log=syslog) nd configure that to rotate the logs

  • on Apache, if the error_log is ini is unset, then errors are sent to stderr, and Apahce writes these to it's error log: and you can configure this to run via a bundled filter which automatically rotates logs

Upvotes: 1

Related Questions