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 Ivan Habunek <iv...@gmail.com> on 2014/01/01 15:25:23 UTC
Re: Multiple Loggers Using Config Array
There's an error in your config file. The "classALogger" should be
under "loggers".
So, instead of this:
'classALogger' => array('level' => 'DEBUG', 'appenders' =>
array('classAAppender')),
You need this:
'loggers' => array(
'classALogger' => array('level' => 'DEBUG', 'appenders' =>
array('classAAppender')),
)
Then if you log to classALogger, it will write to the file. E.g.:
$logger = Logger::getLogger("classALogger");
$logger->info("Yo.");
Regards,
Ivan
On 31 December 2013 21:35, Matt Brooks <im...@gmail.com> wrote:
> Hello,
>
> I’m having trouble getting my second logger working using this configuration array:
>
> Logger::configure(array(
> 'rootLogger' => array('level' => 'DEBUG', 'appenders' => array('default')),
> 'classALogger' => array('level' => 'DEBUG', 'appenders' => array('classAAppender')),
> 'appenders' => array(
> 'default' => array(
> 'class' => 'LoggerAppenderEcho',
> 'layout' => array(
> 'class' => 'LoggerLayoutSimple'
> )
> ),'classAAppender' => array(
> 'class' => 'LoggerAppenderFile',
> 'layout' => array(
> 'class' => 'LoggerLayoutSimple'
> ),
> 'params' => array(
> 'file' => 'log/classA.log',
> 'append' => false
> )
> )
> )
> ));
>
> I can write to the root logger just fine, but can’t seem to log to the classALogger. The classAAppender works fine, it must be the way I am setting up the classALogger. Any suggestions?
> Thanks!
> Matt
Re: Multiple Loggers Using Config Array
Posted by Matt Brooks <im...@gmail.com>.
Thank you Ivan, that was it.
Again, thank you.
Matt
On Jan 1, 2014, at 8:25 AM, Ivan Habunek <iv...@gmail.com> wrote:
> There's an error in your config file. The "classALogger" should be
> under "loggers".
>
> So, instead of this:
> 'classALogger' => array('level' => 'DEBUG', 'appenders' =>
> array('classAAppender')),
>
> You need this:
> 'loggers' => array(
> 'classALogger' => array('level' => 'DEBUG', 'appenders' =>
> array('classAAppender')),
> )
>
> Then if you log to classALogger, it will write to the file. E.g.:
>
> $logger = Logger::getLogger("classALogger");
> $logger->info("Yo.");
>
> Regards,
> Ivan
>
> On 31 December 2013 21:35, Matt Brooks <im...@gmail.com> wrote:
>> Hello,
>>
>> I’m having trouble getting my second logger working using this configuration array:
>>
>> Logger::configure(array(
>> 'rootLogger' => array('level' => 'DEBUG', 'appenders' => array('default')),
>> 'classALogger' => array('level' => 'DEBUG', 'appenders' => array('classAAppender')),
>> 'appenders' => array(
>> 'default' => array(
>> 'class' => 'LoggerAppenderEcho',
>> 'layout' => array(
>> 'class' => 'LoggerLayoutSimple'
>> )
>> ),'classAAppender' => array(
>> 'class' => 'LoggerAppenderFile',
>> 'layout' => array(
>> 'class' => 'LoggerLayoutSimple'
>> ),
>> 'params' => array(
>> 'file' => 'log/classA.log',
>> 'append' => false
>> )
>> )
>> )
>> ));
>>
>> I can write to the root logger just fine, but can’t seem to log to the classALogger. The classAAppender works fine, it must be the way I am setting up the classALogger. Any suggestions?
>> Thanks!
>> Matt