Re: Async Nlog

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Async Nlog

Jarek Kowalski
Administrator
Hi Narendra,
 
Your asynchronous target configuration looks ok.
 
The best way to disable a particular logger completely is to put a final rule at the beginning of your rules:
 
<rules>
    <logger name="SomeLoggerName" final="true" />
    ...
</rules>
 
You could also disable some particular logging levels for some matching loggers:
 
<rules>
    <logger name="Some.Logger.*" levels="Debug,Fatal" final="true" />
    ...
</rules>
 
or disable some levels globally:
 
<rules>
    <logger levels="Trace,Fatal" final="true" />
    ...
</rules>
 
--
Jaroslaw Kowalski
http://blog.jkowalski.net/
----- Original Message -----
Sent: Friday, October 07, 2005 10:37 AM
Subject: Async Nlog

Hi Jaroslaw,
 
gr8 work Jaroslaw...I'm impressed the way you quickly solved our problems.
 
I'm sending you the config settings I made to acheive the Async logging through Nlog
 
    <nlog autoReload="true" >
        <targets>
         <target name="async-db" type="AsyncWrapper" > <!-- batchSize="3"-->
            <!-- database target -->
            <target name="database" type="Database" >
                      <!--database configuration-->
            </target>
   </target>

         <target name="async-mail" type="AsyncWrapper" > <!-- batchSize="3"-->
            <!--Mail Target-->          
            <target name="mail" type="Mail" HTML="true"
                                      <!--mail configuration-->
                        footer            = ""/>
            </target>
        </targets>
        <rules>
                <!--Log Levels-->
                <!--Trace, Debug, Info, Warn, Error, Fatal  maxlevel="Error" -->
            <logger name="WciHttpModule" minlevel="Fatal" writeTo="async-mail" />
            <logger name="*"  minlevel="Error" writeTo="async-db" />
           
        </rules>
    </nlog>

Here I have 2 Targets "mail" and "database" I wrapped these targets inside "async-db" and "async-mail" targets these are of type AsyncWrapper. this is producing the correct desired result, but I want you to have a look on the configuration I made.
 
* Please put your comments, whether it is a correct implementation for asynchronous logging.
* One more thing, How can I Enable\Disable a particular logger through configuration ?
 
looking for your reply.

Thanks,
Narendra Tiwari
NLog Blog