0

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?

3
  • 3
    access.log is not for application logging. Use a PSR-3 logger like Monolog for application logging. Commented Jul 10, 2017 at 19:18
  • @AlexHowansky: Please make your comment a proper answer, I'll accept it. Commented Jul 12, 2017 at 17:59
  • Heh ok. Didn't think it contained enough detail for a full answer, I've elaborated a bit. Commented Jul 12, 2017 at 18:07

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.