For example instead of getting the following
post:Array (
"a" => "b",
"c" => "d"
)
I just get this:
post:Array (\n "a" => "b",\n "c" => "d"\n)
It's really uncomfortable to read this while debugging my code. So if you have any suggestion on why this couldn't work alright, tell me.
I am running it in a Windows7 Putty connected to an Ubuntu virtual server, which runs supposedly it's default Apache/PHP configuration. (well probably not, but as always nobody in the team remembers to have changed anything)
edit: Someone requested the code that writes to the error.log:
<?php
error_log(print_r(array("a"=>"b","c"=>"d"),1));
?>
The commands to view the error log are:
sudo tail -f /var/log/apache2/error.log
sudo vim /var/log/apache2/error.log
sudo cat /var/log/apache2/error.log
In all instances the problem occurs that \n
is not executed as expected.
I also faced the same problem, but after spending a few minutes I got a solution.
When you do tail
, use as below:
sudo tail -f /var/log/apache2/error.log | sed -e 's/\\n/\n/g'
If you want, you can create a file. Give it some name and paste the above command and place that in the /usr/bin/
folder.
For example
vi tailme
With the contents:
#!/bin/bash
tail -f /var/log/apache2/error.log | sed -ue 's/\\n/\n/g'
And put this in /usr/bin/
. Now you can use tailme
as a command.
In some cases (e.g. Mac) using Perl might work better:
tail -100f /var/log/apache2/error.log | perl -pe 's/\\n/\n/g'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With