BUT NOT

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

BUT NOT

xdzgor
Hi - Is it possible to create "exceptions" in logger configurations? Like, log all classes in a hierarchy except one sub-hierarchy?

For example, I have a lot of classes under a namespace (and sub-namespaces) starting "Alpha". I'd like to DEBUG log all these classes, except any under a particular sub-namespace ("Alpha.Import.Core").

Eg something like:

<appender name="one" ...>
  ...
</appender>

<logger name="Alpha" additivity="true" BUT NOT "Alpha.Import.Core">
  <level value="DEBUG" />
  <appender-ref ref="one" />
</logger>

Thanks for any tips,
Peter

Reply | Threaded
Open this post in threaded view
|

Re: BUT NOT

rmashal
Yes. Just add a logger named Alpha.Import.Core and set its log level to OFF.
The new logger will inherit from "Alpha" logger:

<logger name="Alpha.Import.Core">
     <level value="OFF"/>
</logger>

On Tue, Nov 18, 2014 at 10:23 AM, xdzgor <[hidden email]> wrote:
Hi - Is it possible to create "exceptions" in logger configurations? Like,
log all classes in a hierarchy except one sub-hierarchy?

For example, I have a lot of classes under a namespace (and sub-namespaces)
starting "Alpha". I'd like to DEBUG log all these classes, except any under
a particular sub-namespace ("Alpha.Import.Core").

Eg something like:

<appender name="one" ...>
  ...
</appender>

<logger name="Alpha" additivity="true" BUT NOT "Alpha.Import.Core">
  <level value="DEBUG" />
  <appender-ref ref="one" />
</logger>

Thanks for any tips,
Peter





--
View this message in context: http://apache-logging.6191.n7.nabble.com/BUT-NOT-tp53010.html
Sent from the Log4net - Users mailing list archive at Nabble.com.



--

 

email_sig
Ronen Mashal

Software Engineer | Magic Software Enterprises Ltd.

Tel. +972-3-5389215       |       Fax. +972-3-5389333
[hidden email] | www.magicsoftware.com | FacebookTwitterLinkedinYouTubeGoogle+Magic Software Blog

 



DISCLAIMER. Information in this message and its attachments may be privileged or confidential. It is for the exclusive use of the intended recipient(s). 
If you are not one of the intended recipients, you are hereby informed that any use, disclosure, distribution, and/or copying of this information is strictly prohibited. 
If you receive this message in error, please notify the sender immediately and delete all copies of this message. We recommend that you scan your incoming Emails. 
We cannot accept responsibility for any transmitted viruses.

Reply | Threaded
Open this post in threaded view
|

Re: BUT NOT

xdzgor
Hi, thanks. What if I want "Alpha.Import.Core" to go to another appender instead (and all the others to continue to go to appender "one")?

Eg.

<appender name="one" ...>
  ...
</appender>

<appender name="two" ...>
  ...
</appender>

<logger name="Alpha" additivity="true" BUT NOT "Alpha.Import.Core">
  <level value="DEBUG" />
  <appender-ref ref="one" />
</logger>

<logger name="Alpha.Import.Core" additivity="false" >
  <level value="DEBUG" />
  <appender-ref ref="two" />
</logger>
Reply | Threaded
Open this post in threaded view
|

RE: BUT NOT

Joe Joe-3
Use additivity="false" in your configuration - look for "Additivity" in the
log4net user manual:
http://logging.apache.org/log4net/release/manual/introduction.html


-----Original Message-----
From: xdzgor [mailto:[hidden email]]
Sent: 18 November 2014 10:22
To: [hidden email]
Subject: Re: BUT NOT

Hi, thanks. What if I want "Alpha.Import.Core" to go to another appender
instead (and all the others to continue to go to appender "one")?

Eg.

<appender name="one" ...>
  ...
</appender>

<appender name="two" ...>
  ...
</appender>

<logger name="Alpha" additivity="true" BUT NOT "Alpha.Import.Core">
  <level value="DEBUG" />
  <appender-ref ref="one" />
</logger>

<logger name="Alpha.Import.Core" additivity="false" >
  <level value="DEBUG" />
  <appender-ref ref="two" />
</logger>




--
View this message in context:
http://apache-logging.6191.n7.nabble.com/BUT-NOT-tp53010p53012.html
Sent from the Log4net - Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

RE: BUT NOT

xdzgor
Thanks, but additivity is set to false in the "Alpha.Import.Core" logger. If I also set it to false in the "Alpha" logger, then I don't see any logging from classes in the namespace "Alpha.Web.UI" or "Alpha.Util". Is this expected behaviour?
Reply | Threaded
Open this post in threaded view
|

RE: BUT NOT

Joe Joe-3
Apologies, I didn't read your original properly.
Your configuration should work as it stands:, i.e.:

- Alpha.Import.Core and its child loggers will log to "two" only
- Alpha and all its child loggers except Alpha.Import.Core and children will
log to "one" only:

<logger name="Alpha">
  <level value="DEBUG" />
  <appender-ref ref="one" />
</logger>

<logger name="Alpha.Import.Core" additivity="false" >
  <level value="DEBUG" />
  <appender-ref ref="two" />
</logger>



-----Original Message-----
From: xdzgor [mailto:[hidden email]]
Sent: 18 November 2014 18:01
To: [hidden email]
Subject: RE: BUT NOT

Thanks, but additivity is set to false in the "Alpha.Import.Core" logger. If
I also set it to false in the "Alpha" logger, then I don't see any logging
from classes in the namespace "Alpha.Web.UI" or "Alpha.Util". Is this
expected behaviour?



--
View this message in context:
http://apache-logging.6191.n7.nabble.com/BUT-NOT-tp53010p53021.html
Sent from the Log4net - Users mailing list archive at Nabble.com.