Using log4php with Apache httpd's access_log and/or error_log?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Using log4php with Apache httpd's access_log and/or error_log?

Raj, Pavan (CCI-Atlanta)
I am trying to use log4php with a PHP application that runs on Apache 2.2.3. When the script is executed using CLI, the log4php bits are invoked correctly and log entries are created as expected. But when the script is accessed using a web browser, the log file(s) defined in the log4php config are created but nothing gets written to them. Where should I look? How do I figure out why log4php doesn’t write to the log file?
 
Thanks in advance!
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Using log4php with Apache httpd's access_log and/or error_log?

Ivan Habunek
Hi Raj,

Can you provide the config file you're using. Also, which OS?

Regards,
Ivan

On 15 June 2012 23:05, Raj, Pavan (CCI-Atlanta) <[hidden email]> wrote:

> I am trying to use log4php with a PHP application that runs on Apache 2.2.3.
> When the script is executed using CLI, the log4php bits are invoked
> correctly and log entries are created as expected. But when the script is
> accessed using a web browser, the log file(s) defined in the log4php config
> are created but nothing gets written to them. Where should I look? How do I
> figure out why log4php doesn’t write to the log file?
>
> Thanks in advance!
>
>
Reply | Threaded
Open this post in threaded view
|

RE: Using log4php with Apache httpd's access_log and/or error_log?

Raj, Pavan (CCI-Atlanta)
Ivan,

Thanks for your response. It turned out that the log files were created by a user other than the "apache" user, so "apache" couldn't write to the log file. I started seeing log entries once I deleted the existing log files and allowed the application to create them.

However, I would still like your help figuring out why "error.log" in the config below stays at 0 bytes. The "main.log" file gets entries with log level "error", but nothing goes in the "error.log" file. I have tried with and without the LoggerFilterDenyAll parameter.

1. OS: Red Hat Enterprise Linux Server 5.6, Apache 2.2.3, PHP 5.3.3.
2. Config:

$config = array(
        'appenders' => array(
                'main' => array(
                        'class' => 'LoggerAppenderFile',
                        'layout' => array(
                                'class' => 'LoggerLayoutPattern',
                                'params' => array(
                                        'ConversionPattern' => "%d{Y-m-d H:i:s} '%p' %c: %m (at %F line %L)%n"
                                )
                        ),
                        'params' => array(
                                'file' => '/tmp/main.log'
                        )
                ),
                'errorLog' => array(
                        'class' => 'LoggerAppenderFile',
                        'layout' => array(
                                'class' => 'LoggerLayoutPattern',
                                'params' => array(
                                        'ConversionPattern' => "%d{Y-m-d H:i:s} '%p' %c: %m (at %F line %L)%n"
                                )
                        ),
                        'params' => array(
                                'file' => '/tmp/error.log',
                                'threshold' => 'error'
                        ),
                        'filters' => array(
                                array(
                                        'class' => 'LoggerFilterLevelRange',
                                        'params' => array(
                                                'LevelMin' => 'error',
                                                'LevelMax' => 'fatal'
                                        )
                                ),
                                array(
                                        'class' => 'LoggerFilterDenyAll'
                                )
                        )
                ),
                'emailNotice' => array(
                        'class' => 'LoggerAppenderMail',
                        'layout' => array(
                                'class' => 'LoggerLayoutPattern',
                                'params' => array(
                                        'ConversionPattern' => "%d{Y-m-d H:i:s} '%p' %c: %m (at %F line %L)%n"
                                )
                        ),
                        'params' => array(
                                'from' => 'AppHost <[hidden email]>',
                                'to' => '[hidden email]',
                                'subject' => 'PHP Error'
                        ),
                        'filters' => array(
                                array(
                                        'class' => 'LoggerFilterLevelRange',
                                        'params' => array(
                                                'LevelMin' => 'error',
                                                'LevelMax' => 'fatal'
                                        )
                                ),
                                array(
                                        'class' => 'LoggerFilterDenyAll'
                                )
                        )
                )
        ),
        'loggers' => array (
                'main' => array(
                        'level' => 'ALL',
                        'additivity' => true,
                        'appenders' => array(0=>'errorLog', 1=>'emailNotice')
                )
        ),
        'renderers' => array(),
        'rootLogger' => array(
                'level' => 'DEBUG',
                'appenders' => array('main')
        )
);


Thank you,
Pavan Raj

-----Original Message-----
From: Ivan Habunek [mailto:[hidden email]]
Sent: Saturday, June 16, 2012 3:15 AM
To: Log4PHP User
Subject: Re: Using log4php with Apache httpd's access_log and/or error_log?

Hi Raj,

Can you provide the config file you're using. Also, which OS?

Regards,
Ivan

On 15 June 2012 23:05, Raj, Pavan (CCI-Atlanta) <[hidden email]> wrote:

> I am trying to use log4php with a PHP application that runs on Apache 2.2.3.
> When the script is executed using CLI, the log4php bits are invoked
> correctly and log entries are created as expected. But when the script
> is accessed using a web browser, the log file(s) defined in the
> log4php config are created but nothing gets written to them. Where
> should I look? How do I figure out why log4php doesn't write to the log file?
>
> Thanks in advance!
>
>