NLog and final rules

474 views
Skip to first unread message

John Tyson

unread,
May 31, 2013, 12:39:22 PM5/31/13
to nlog-...@googlegroups.com

Very often I want to exclude logging from a specific chatty logger up to a certain level. Unfortunately, the first of the following rules is final for all levels of that logger, so that the second rule (which is simply my default rule) will not log anything from it:

<logger name="ChattyLogger" maxlevel="Warn" writeTo="blackhole" final="true" />

<logger name="*" minlevel="Info" writeTo="default" />

One possibility is to use filters instead:

<logger name="ChattyLogger" writeTo="blackhole">
  <filters>
    <when condition="level&lt;=LogLevel.Warn" action="IgnoreFinal" />
  </filters>
</logger>

<logger name="*" minlevel="Info" writeTo="default" />

But the syntax is ugly, especially the length and the need to escape the condition expression.

Since this seems like such a common requirement, I'm wondering if I overlooked something.

I'm using nlog under Silverlight, but I presume that shouldn't matter.

(I've posted the same question on StackOverflow here, but without answers so far.)

Kim Christensen

unread,
Jun 2, 2013, 6:48:46 PM6/2/13
to nlog-...@googlegroups.com

Hi,

Actually thought I've answered this on SO, but apparently not :-)
Currently there are no other way than using filters.

--
You received this message because you are subscribed to the Google Groups "NLog-Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nlog-users+...@googlegroups.com.
To post to this group, send email to nlog-...@googlegroups.com.
Visit this group at http://groups.google.com/group/nlog-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Kim Christensen

unread,
Jun 2, 2013, 6:50:47 PM6/2/13
to nlog-...@googlegroups.com

I just thought of something, I'll have to check out our first.

Kim Christensen

unread,
Jun 3, 2013, 1:36:35 PM6/3/13
to nlog-...@googlegroups.com
After checking, it seems like this aren't possible without filters at the moment
Reply all
Reply to author
Forward
0 new messages