Search code examples
perlapachenewlineerror-log

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.


Solution

  • 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.