On Mon, Nov 28, 2022 at 4:13 PM Derick Rethans <der...@php.net> wrote:
> On Fri, 21 Oct 2022, Mikhail Galanin via internals wrote: > > Looking into the future, probably we would like to have this format > > configurable, if so it looks easy to do but still I can't see an easy > > way to handle the microseconds issue. > > Making things configurable requires an ini setting, which we generally > don't like to add. It wouldn't really work in this situation, as > warnings/errors happen either before or during INI file parsing, meaning > that it can't (yet) use the new format. > > I'm not sure I understand this because error_log itself is already configurable using INI so obviously if the file path is specified there, then the logged time format should be the same if configured in ini. By default there is no error log so errors that happen before should not be logged anyway. Or do I miss anything? > > Could you please help me to find the right way and share your thoughts > > about this topic (maybe there are strong objections against such a > > change)? > > I don't think we should change anything in PHP. Instead, use your > system's syslog. You can configure PHP to send all warnings to syslog by > setting "log_errors=1 error_log=syslog" in PHP.ini. In order to separate > out just the PHP issues, you can also set "syslog.facility=local1" (or > any other local). > > On Unix systems, you can configure syslog to add milliseconds to the log > file messages. See https://askubuntu.com/a/1266114 > > If your system already uses systemd and journald, then you don't have to > use any configuration settings, and you can query the journal with: > > journalctl -o short-iso-precise -r --facility=local1 > > A PHP warning would show up in there, with something like: > > $ sudo journalctl -o short-iso-precise -r --facility=local1 > 2022-11-28T16:06:53.862980+0000 gargleblaster php[3143059]: PHP Warning: > Undefined variable $fasd in Command line code on line 1 > > It is not always practical to use system log for PHP especially for users using more than one FPM pool. Log files also offer some advantages like easier export and post processing so I think there is still place for log files and we should support the users that still use them which includes new features like this one. Cheers Jakub