Seldaek / monolog

Sends your logs to files, sockets, inboxes, databases and various web services
https://seldaek.github.io/monolog/
MIT License
21.04k stars 1.9k forks source link

ErrorHandler::register not working as expected #1915

Closed kaihendry closed 2 weeks ago

kaihendry commented 2 months ago

Monolog version 3.7

https://gist.github.com/kaihendry/6ad32ed135e3d679e6dd896365b252cb

The error handler is not working as expected, it shows:

  {"level":"info","ts":1726946030.4808884,"msg":"capture me monolog","syslog_level":"notice"}
stof commented 2 months ago

what do you mean by "it is not working as expected" ?

kaihendry commented 2 months ago

I expected monolog to hook into error_log

stof commented 2 months ago

PHP's error_log function does not report its messages to the PHP error handler system. It directly sends it to the PHP system logger, which is not hookable in userland.

Seldaek commented 2 weeks ago

Right the way to trigger it is to call trigger_error().. But really if you wanna trigger the logger, please call the logger :)