Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logging: Allow logging to web server error_log #1004

Merged
merged 1 commit into from
Jan 8, 2018
Merged

Conversation

jtojnar
Copy link
Member

@jtojnar jtojnar commented Dec 6, 2017

This PR adds a new configuration option logger_destination allowing to choose between Monolog’s ErrorLogHandler and StreamHandler.

@jtojnar jtojnar added this to the 2.18 milestone Dec 6, 2017
@jtojnar
Copy link
Member Author

jtojnar commented Dec 6, 2017

I am actually not sure if there is any benefit of using error_log compared to file:php://stderr.

@jtojnar
Copy link
Member Author

jtojnar commented Dec 6, 2017

It looks like the behaviour is slightly different on different servers, however, both go through stderr to server’s error log (SAPI error log).

Apache httpd

Both are written to httpd error log:

  • error_log function: [Wed Dec 06 02:12:51.537817 2017] [php7:notice] [pid 20094] [client ::1:49470] [2017-12-06 02:12:51] selfoss.DEBUG: Establish database connection \n
  • stderr: [2017-12-06 02:25:33] selfoss.DEBUG: Establish database connection

nginx + php-fpm

Both are written to php-fpm pool error log (system journal in my case)

  • error_log function: Dec 06 03:18:45 srv php-fpm[328]: [WARNING] [pool reader] child 26568 said into stderr: "NOTICE: PHP message: [2017-12-06 03:18:45] selfoss.DEBUG: Establish database connection "
  • stderr: Dec 06 03:20:43 srv php-fpm[328]: [WARNING] [pool reader] child 26568 said into stderr: "[2017-12-06 03:20:43] selfoss.DEBUG: Establish database connection "

It looks like using stderr leads to more concise logs.

Edit: It looks like php-fpm discards stderr by default (see catch_workers_output) so the error_log option is useful after all.

@jtojnar jtojnar force-pushed the logger-dest branch 2 times, most recently from 6ee5c2d to 3df3382 Compare December 6, 2017 03:45
@jantman
Copy link

jantman commented Dec 6, 2017

I haven't tested this yet but it looks absolutely wonderful for people like me who are trying to run selfoss in Docker and have existing log management being done at the docker level. This makes it much easier to run selfoss like a proper 12 factor app.

Thanks so much!

@jtojnar jtojnar mentioned this pull request Dec 9, 2017
This commit adds a new configuration option `logger_destination`
allowing to choose between Monolog’s ErrorLogHandler and StreamHandler.
@jtojnar jtojnar merged commit b1f2263 into master Jan 8, 2018
@jtojnar jtojnar deleted the logger-dest branch January 9, 2018 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants