You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4php-user@logging.apache.org by "Raj, Pavan (CCI-Atlanta)" <Pa...@cox.com> on 2012/06/15 23:05:07 UTC

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

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!



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

Posted by "Raj, Pavan (CCI-Atlanta)" <Pa...@cox.com>.
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 <pa...@cox.com>',
                                'to' => 'pavan.raj@cox.com',
                                '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:ivan.habunek@gmail.com] 
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) <Pa...@cox.com> 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!
>
>

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

Posted by Ivan Habunek <iv...@gmail.com>.
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) <Pa...@cox.com> 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!
>
>