Click here to Skip to main content
15,886,518 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

NLog email buffering wrapper

Rate me:
Please Sign up or sign in to vote.
4.50/5 (2 votes)
12 Mar 2011CPOL 11.7K   1   1
I have found this link which works well without having to write your class above. <target xsi:type="PostFilteringWrapper"...
I have found this link which works well without having to write your class above.

XML
<targets>
        <target name="console" xsi:type="Console" />
        <target name="papercut" xsi:type="BufferingWrapper" bufferSize="100">
            <target xsi:type="PostFilteringWrapper" defaultFilter="level >= LogLevel.Error">
                <target xsi:type="Mail"
                    name="papercut"
                    subject="Your app has errors"
                    to="somebody@domain.net"
                    from="someemail@domain.net"
                    smtpServer="localhost" />
                <when exists="level >= LogLevel.Error" filter="level >= LogLevel.Info"/>
            </target>
        </target>
    </targets>
    <rules>
        <logger name="*" minlevel="Debug" writeTo="console" />
        <logger name="*" minlevel="Debug" writeTo="papercut"  />
    </rules>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) www.ByBox.com
United Kingdom United Kingdom
C++ and C# Developer for 21 years. Microsoft Certified.

UK Senior software developer / team leader.

I've been writing software since 1985. I pride myself on designing and creating software that is first class. That means it has to be fast, scalable, and with good use of design patterns.

I have done everything from risk analysis and explosion modelling, banking systems, to highly scalable multi-threaded arrival and departure screens in many leading airports, to state of the art wireless warehouse systems.

Comments and Discussions

 
QuestionAlternative solution using AutoFlushWrapper Pin
Rolf Kristensen17-Feb-23 23:05
Rolf Kristensen17-Feb-23 23:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.