Change the format of the error log: ini_set ('error_append_string', 'string') and ini_set ('error_prepend_string', 'string') does nothing

This is what I say php:

<?php error_reporting(E_ALL); ini_set('display_errors', '0'); ini_set('log_errors', 1); ini_set('error_log', 'errors.log'); ini_set('error_append_string', 'APP'); ini_set('error_prepend_string', 'PRE'); ?> 

We hope that I will receive all errors reported in one file, with the message "PRE" before the message and "APP" after the message. (My goal is to do PRE and APP in / n / r or something else ...)

But the error log looks like this:

[14-May-2013 00:16:26] PHP note: Undefined variable: nonexistentvariable in /home/www/dir/index.php on line 14 [May 14, 2013 00:16:28] PHP note: Undefined variable : nonexistentvariable in /home/www/dir/index.php on line 14

No PRE, No APP ...

How can I get it there so that in my error report file every error appears in a new line, and not in the error line that did not help me?

EDIT: So I noticed this with ini_set ('display_errors', '1'); the lines "APP" and "PRE" are displayed on the page in an error message.

This means that I really need to find out where I can change the format of how php logs errors. For example, all this timestamp - where is it indicated?

EDIT: It is not possible to change the php log errors method, you have to make your own error handler.

ANSWER: To really achieve what I was going to, I asked another question (more precisely). How to change the way php errors are written to the error log file?

+4
source share
2 answers

Since the documentation says nothing, I checked your example. I realized that error_append/prepend_string only works for displayed but not registered errors

My goal is to make PRE and APP in / n / r or something like that.

For this you need to use a regular expression. It should be possible since every log message starts with almost the same prefix. Will cook one ....

+4
source

check phpinfo(); after ini_sets

+2
source

Source: https://habr.com/ru/post/1480597/


All Articles