apache PHP 错误日志和换行符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1203664/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP error log and newline chars
提问by Chris Burgess
What's the PHP config setting which allows or prevents newlines in debug output from being escaped?
允许或防止调试输出中的换行符被转义的 PHP 配置设置是什么?
On two different installs (a dev laptop running MAMP/OSX, and a dev server running debian) I see different results in the error logs when debugging.
在两个不同的安装(运行 MAMP/OSX 的开发笔记本电脑和运行 debian 的开发服务器)上,我在调试时在错误日志中看到不同的结果。
error_log(print_r(array(1,2,4),1));
On Debian this appears in /var/log/apache2/error.log as
在 Debian 上,它出现在 /var/log/apache2/error.log 中
[Thu Jul 30 11:32:34 2009] [error] [client 118.93.246.104] Array\n(\n [0] => 1\n [1] => 2\n [2] => 4\n)\n, referer: http://dev.example.org/
On OSX this appears in /Applications/MAMP/logs/php_error_log as
在 OSX 上,它出现在 /Applications/MAMP/logs/php_error_log 中
[30-Jul-2009 11:34:00] Array
(
[0] => 1
[1] => 2
[2] => 4
)
I prefer the MAMP way for debugging (apart from relocating logfiles to the /Applications directory).
我更喜欢 MAMP 调试方式(除了将日志文件重定位到 /Applications 目录)。
Thanks!
谢谢!
采纳答案by hobodave
Chris, you should be able to change the error_log directive in your php.ini on Debian to point to a file. If this is undefined, it will go through syslog which doesn't support multiple lines.
克里斯,您应该能够在 Debian 上更改 php.ini 中的 error_log 指令以指向一个文件。如果这是未定义的,它将通过不支持多行的系统日志。
Details:
细节:
error_logfunction
error_logdirective
回答by regexp
The problem is caused when the Apache process can't write into the error_log file, so the syslog writes into the file instead. The syslog messes up the line breaks.
该问题是由于Apache进程无法写入error_log文件而导致的,因此syslog写入文件。系统日志弄乱了换行符。
So just do:
所以只需这样做:
chmod 777 error.log
This should solve your problem.
这应该可以解决您的问题。

