aidan
aidan

Reputation: 9576

Why does my Apache2::Log output replace newlines with \n?

I've set up multiple vhosts under apache2 / mod_perl. I used the ErrorLog directive to get a separate error log for each vhost. This only worked as expected when I used Apache2::Log. 'warn' would only log to the regular error log.

So that's all working. Finally. But there's one issue remaining: When I log via $r->log_error, I find that newlines are replaced with \n

Any idea why this happens, and how it can be fixed?

Thanks.

Upvotes: 2

Views: 834

Answers (3)

pgupta
pgupta

Reputation: 1

i know this is very old thread, but still coming on top on google results, so just to help all, the following changes in mod_perl.pl did helped me:

comment out below:

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

the above is for: Make warnings go to the virtual host's log and not the main server log.

i hope this helps anyone out there like me :)

Upvotes: 0

Dave
Dave

Reputation: 1

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

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

Upvotes: 0

mpeters
mpeters

Reputation: 4778

This is not a mod_perl problem, but an Apache one. Apparently there are some security concerns with printing unescaped output to the error logs (I'm not entirely sure why) so you have to explicitly enable this in Apache when building/configuring it using this:

CFLAGS=-DAP_UNSAFE_ERROR_LOG_UNESCAPED ./configure

If you're using an already installed apache, there's not much you can do to change this.

Upvotes: 8

Related Questions