Why is my Apache2 :: Log output replacing newlines \ n?

I have installed several vhosts under apache2 / mod_perl. I used a directive ErrorLog

to get a separate error log for each vhost. This only worked when I was using Apache2 :: Log. 'warn' will only be logged in the regular error log.

So everything works. Finally. But one problem remains: when I log via $ r-> log_error, I find that new lines are replaced with\n

Any idea why this is happening and how can I fix it?

Thank.

+2


source to share


3 answers


This is not a mod_perl problem, but Apache. Apparently there are some security issues when printing non-fledged output to error logs (I'm not really sure why), so you need to explicitly enable this in Apache when building / configuring it with this:

CFLAGS=-DAP_UNSAFE_ERROR_LOG_UNESCAPED ./configure

      



If you are using apache already installed you cannot do this to change this.

+8


source


If you have a built-in install, you can use this line of code to fix the problem, but it must be included in every page execution in your vhost, for example in your header.php or config.php file.



ini_set('error_log','/var/log/apache2/error.log');

      

0


source


I know this is a very old thread, but still at the top of google results, so to help everyone, the following changes to mod_perl.pl really helped me:

comment below:

BEGIN { *CORE::GLOBAL::warn = \&Apache2::ServerRec::warn; }

      

above for: Provide warnings to the virtual host log rather than the primary server log.

Hope this helps someone like me :)

0


source







All Articles