Multiple Loggers Using Config Array

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

Multiple Loggers Using Config Array

Matt Brooks
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple Loggers Using Config Array

Ivan Habunek
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 <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple Loggers Using Config Array

Matt Brooks
Thank you Ivan, that was it.

Again, thank you.
Matt

On Jan 1, 2014, at 8:25 AM, Ivan Habunek <[hidden email]> 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 <[hidden email]> 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

Loading...