change error log output format: ini_set('error_append_string', 'string') and ini_set('error_prepend_string', 'string') does nothing

This is what I tell php to do:

<?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');
?>

Hoping that I would get all errors reported in one file, with "PRE" before the message and "APP" after the message. (My goal is to make PRE and APP into /n /r or something...)

But my error reporting log looks like this:

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

No PRE, no APP...

How do I get it in there, so that my error reporting file will have each error on a newline, rather than a loooong string of errors that's not helpful to me?

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

That means I really need to find out where I can change the format for how php logs the errors. For example this whole timestamp thing - where is that specified?

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

ANSWER: To truly achieve what I was going to, I asked a different question (to be more precise). How to change the way PHP writes errors in the error log file?

Answers


As the documentation says nothing to that, I have tested your example. I realized that error_append/prepend_string only works for displayed but not logged errors

My goal is to make PRE and APP into /n /r or something...

You should use a regex for that. Should be possible, as every log messages starts with nearly same prefix. Will prepare one....


check phpinfo(); after ini_sets


Need Your Help

Surpress double photos in Google Glass timeline?

google-mirror-api google-glass

Currently when you share a photo from Glass, that action leaves a card in your timeline. (For example, sharing a pic to G+ results in a second timeline card of that picture with a little G+ icon in...

PowerShell MySQL query syntax

mysql powershell powershell-v2.0 mysql-connector

I want to insert data into my MySQL database using PowerShell.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.