简体   繁体   中英

PHP: Sending info to access.log, errors to error.log

I have a legacy app that runs under PHP and Apache.

It does all its logging via error_log() , which ends up in Apache's error.log .

I'd like to only send error messages to error.log , and send other logging to access.log .

What are my options? I would rather not drastically overhaul the Apache's logs format, because other tools parse it.

  • I see a solution using apache_note .
  • I can imagine that making both Apache and PHP write to syslog, and configuring syslog to filter the messages by source and severity would allow me to have neat access.log and error.log with two or more writers.

Am I missing a simpler solution?

access.log is intended to record web server connection activity, and should not be used for application logging. See PSR-3 for a definition of a logger interface. This is implemented by popular packages like Monolog .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM