Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Error log has extra carriage returns?

Tags:

php

I use WAMP, and in my php.ini file I have:

error_log = "d:/php_error.log"

When I open that file, I see:

[26-Jun-2013 05:35:57 UTC] PHP Warning:  Division by zero in D:\....

[26-Jun-2013 05:35:57 UTC] PHP Stack trace:

[26-Jun-2013 05:35:57 UTC] PHP   1. {main}() D:\....

[26-Jun-2013 05:35:57 UTC] PHP   2. Zend_Application->run()...

etc

The problem is that there are extra Carriage returns. I.e. I am expecting to rather have this:

[26-Jun-2013 05:35:57 UTC] PHP Warning:  Division by zero in D:\....
[26-Jun-2013 05:35:57 UTC] PHP Stack trace:
[26-Jun-2013 05:35:57 UTC] PHP   1. {main}() D:\....
[26-Jun-2013 05:35:57 UTC] PHP   2. Zend_Application->run()...
etc

What could be causing this?

UPDATE

I changed "error_append_string" and "error_prepend_string" to "". I also checked and the entries after a line are:

 [LINE]CR
 CRLF
 [LINE]CR
 etc

I.e. Carriage Returns and LineFeed symbols...

like image 431
coderama Avatar asked Jun 26 '13 05:06

coderama


1 Answers

This might have something to do with syslog messing you up. So PHP adds the CR, and then Windows' syslog goes in and puts an extra CRLF in it when processing the log "line\n" request.

See these related questions, where users had other problems with new line & error_log under other operating systems:

PHP error_log outputting line breaks as literal "\n" strings on Mac OSX

PHP error log and newline chars

In particular, this may happen when the user that Apache runs as does not have permission to write to the file, or the error_log directive in your php.ini is unset (or defined as syslog). More details here: http://www.php.net/manual/en/errorfunc.configuration.php#ini.error-log

As for the log file itself, you may try to experiment with it by giving it 777 permission, or creating the file yourself instead of letting the system create it (or vice-versa). Some users report different problems/solutions with each of these tweaks.

like image 179
i Code 4 Food Avatar answered Sep 23 '22 20:09

i Code 4 Food