PHP错误日志和换行符 [英] PHP error log and newline chars

查看:106
本文介绍了PHP错误日志和换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在两个不同的安装(运行MAMP / OSX的开发笔记本电脑和一个dev服务器运行debian)我在调试时看到错误日志中的不同结果。

  error_log(print_r 4),1)); 

在Debian上,这出现在/var/log/apache2/error.log中,作为

  [Thu Jul 30 11:32:34 2009] [error] [client 118.93.246.104] Array\\\
(\\\
[0] => 1\\\
[1] => 2\\\
[2] => 4\\\
)\\\
,refferer:http://dev.example.org/

在OSX上,这出现在/ Applications / MAMP / logs / php_error_log中,作为

  [2009年7月30日11:34:00]数组

[0] => 1
[1] => 2
[2] => 4

我更喜欢MAMP调试方式(将日志文件重定位到/ Applications目录除外)。



谢谢!

解决方案

Chris,你应该能够改变在Debian的php.ini中的error_log指令指向一个文件。如果这是未定义的,它将通过不支持多行的syslog。



详细信息:



error_log 功能



error_log 指令


What's the PHP config setting which allows or prevents newlines in debug output from being escaped?

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.

error_log(print_r(array(1,2,4),1));

On Debian this appears in /var/log/apache2/error.log as

[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

[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).

Thanks!

解决方案

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.

Details:

error_log function

error_log directive

这篇关于PHP错误日志和换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆