65.9K
CodeProject is changing. Read more.
Home

NLog email buffering wrapper

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.50/5 (2 votes)

Mar 12, 2011

CPOL
viewsIcon

11954

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.
<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>