Click here to Skip to main content
15,892,005 members
Articles / Programming Languages / C#

Logging with NLog

Rate me:
Please Sign up or sign in to vote.
1.68/5 (13 votes)
6 Jan 20073 min read 52.3K   69   20  
The article describes how to configure nlog to log reports as per your requirement
<?xml version="1.0" encoding="windows-1250" ?>
<?xml-stylesheet type="text/xsl" href="style.xsl" ?>
<content lang="en" id="releasenotes">
    <h1>Release Notes</h1>
    <table width="100%">
        <tr class="altreleasenote">
            <td class="newsdate">2006-02-20</td>
            <td class="newstext">
                <p><b style="color: red; font-size: 16px">NLog 0.95 has been released!</b></p>
                <p>
                    Major changes:
                </p>
                <ul>
                    <li>Added new Trace level, more verbose than the Debug level.</li>
                    <li>Added a new <a href="http://www.nlog-project.org/conditions.html">conditions language</a> which 
                        lets you write powerful filtering conditions while keeping the syntax natural and readable</li>
                    <li><b><u>BREAKING CHANGE</u></b>: Renamed <code>Target.Append()</code> method to <code>Target.Write()</code></li>
                    <li>Added <code>Target.Write(LogEvent[] manyEvents)</code> for cases where the
                        target can optimize group writes</li>
                    <li>Added global log threshold and configurability at the config level (<x><nlog globalThreshold="..." /></x>)</li>
                    <li>Added support for <x><variable name="" value="" /></x> configuration element. Details are <a href="http://sourceforge.net/mailarchive/message.php?msg_id=12189220">here</a>.</li>
                    <li>Added infrastructure for <a href="http://sourceforge.net/mailarchive/message.php?msg_id=13149726">compound targets and wrapper targets</a>.</li>
                    <li>Added detailed documentation with examples for many targets, both on the website and in the help file</li>
                </ul>
                <p>
                    Bugs fixed:
                </p>
                <ul>
                    <li>Fixed the filter configuration bug as reported by Ron Grabowski</li>
                    <li>
                        Fixed a serious reentrancy bug which caused all sorts of problems
                        when formatted message included a parameter where ToString
                        did the logging itself. More details <a href="http://trac.nlog-project.org/nlog/ticket/64">here</a>.
                    </li>
                    <li>Fixed a nullref exception when no config file was present.</li>
                    <li>Fixed support for CC field in the Mail target</li>
                    <li>Fixed Close() behaviour for unnamed targets (like the ones configured by SimpleConfigurator)</li>
                    <li>Typos in the code prevented Chainsaw target	from working properly.</li>
                    <li>${callsite} not working with database parameters</li>
                    <li>${callsite} doesn't work with MethodCall target and NLogViewer target</li>
                    <li>Connection string builder omits ; after Server parameter</li>
                    <li>Fixed the Trace target in Release mode by defining TRACE symbol</li>
                    <li>Fixed VS.NET Compact Framework project file</li>
                    <li>Fixed the Trace target in Release mode by defining TRACE symbol</li>
                    <li>Fixed bugs related to ${asp-request:cookie} and ${aspnet-request:cookie}</li>
                    <li>Fixes for case-insensitive parsing of the config files.</li>
                    <li>fixed CompactFramework build</li>
                </ul>
                <p>
                    New additions:
                </p>
                <ul>
                    <li>Added <x><when condition="..." action="..." /></x> filter which uses condition expressions</li>
                    <li>Added <code>${aspnet-sessionid}</code> to access (guess!) ASP.NET session ID</li>
                    <li>Added ${processname}, ${processid} layout renderers</li>
                    <li>Added ASPNetBufferingWrapper target which buffers and post-processes the entire ASP.NET
                        request (requires you to use the NLogHttpModule)</li>
                    <li>Added PostFilteringWrapper target which is able to filter log events based on a buffer 
                        as a whole. Details are <a href="http://sourceforge.net/mailarchive/forum.php?thread_id=8806711&amp;forum_id=41984">here</a>.</li>
                    <li>Added GDC (Global Diagnostics Context) and ${gdc} layout renderer which
                        is a global (as opposed to per-thread) version of MDC and ${mdc}</li>
                    <li>Added authentication options to the Mail target (thanks Ron).</li>
                    <li>Added support for caching layout results per logEvent which makes them transportable across threads</li>
                    <li>Added ${log4jxmlevent} which renders <a href="http://logging.apache.org/log4j">log4j</a>-compatible XML event</li>
                    <li>Added <a href="http://www.nlog-project.org/targets.html">wrapper targets</a>: AsyncWrapper, AutoFlushWrapper, BufferingWrapper,  RepeatingWrapper, RetryingWrapper</li>
                    <li>Added <a href="http://www.nlog-project.org/targets.html">compound targets</a> (fallback, randomize, roundrobin, split)</li>
                    <li>Added ${windows-identity} layout renderer.</li>
                    <li>Added MSMQ target (Message Queue)</li>
                    <li>Added EventLog target</li>
                    <li>Added ${pc} - Performance Counter layout renderer</li>
                    <li>Added SimpleConfigurator.ConfigureForTargetLogging() and SimpleConfigurator.ConfigureForFileLogging()</li>
                    <li>Added Debugger target</li>
                    <li>Added ${logger:shortname=true} option.</li>
                    <li>Added ${stacktrace} layout renderer, 3 different logging formats. Details are <a href="http://sourceforge.net/mailarchive/message.php?msg_id=12029446">here</a>.</li>
                    <li>Added ${newline} layout renderer.</li>
                    <li>Added IgnoreCase option to filters</li>
                </ul>
                <p>
                    Other changes:
                </p>
                <ul>
                    <li>Project web site has been moved to <a href="http://www.nlog-project.org/">http://www.nlog-project.org/</a></li>
                    <li>Patch by Yuri Mamrukov to simplify InternalLogger configuration from environment
                        variables and/or App.config settings. Fixes some nasty bug there. 
                        More details are available <a href="http://sourceforge.net/mailarchive/forum.php?thread_id=9260106&amp;forum_id=42511">here</a>.</li>
                    <li>Excluded NLogViewer from build and project. It will become be a separate project <a href="http://viewer.nlog-project.org/">here</a>.</li>
                    <li>Added batch NLogC compilation, added installer and nlogc binary snapshot.</li>
                    <li>Added some minimal VB.NET test code</li>
                    <li>Added some meaningful error message when a named target is not defined.</li>
                    <li>Added many unit tests</li>
                </ul>
            </td>
        </tr>
        <tr class="releasenote">
            <td class="newsdate">2005-06-09</td><td class="newstext">
                <p><b>NLog 0.9 has been released!</b></p>

                <p>Major changes:</p>
                <ol>
                    <li><b>API redesign/rename.</b></li>
                    <p>"Appender" has been renamed as "Target" and 
                        "LayoutAppender" as "LayoutRenderer". This should make it easier for 
                        people to understand the basic concepts ("layout appender" wasn't a good 
                        idea). Old configuration file format is still supported. Old extension code 
                        should require nothing more than a search/replace and a recompile.
                    </p>
                    <li>
                        Improved logging and non-logging speed by removing most abstraction
                        from the Logger class.
                    </li>
                    <p>
                        A single non-logging operation takes only 7 
                        nanoseconds which means 140.000.000 logs/second). Logging API should remain 
                        the same.
                    </p>
                    <li>
                        Changed the way the configuration file is parsed. Now elements are 
                        processed top-down and you can change the order of the sections as well as 
                        the elements you reference have been processed before. 
                    </li>
                </ol> 

                <p>Bugs fixed:</p>
                <ol>
                    <li>Fixed an old bug where appenders were incorrectly combined into a chain.</li>
                </ol>

                <p>New additions:</p>
                <ol>
                    <li>Network target (capable of sending messages over TCP and UDP, HTTP to be 
                        supported)</li>
                    <li>Preliminary NLogViewer target and a sketchy, but already usable viewer 
                        application. "Chainsaw" target should probably be added as well.</li>
                    <li>Added LogManager.GlobalThreshold</li>
                    <li>API documentation, target, layout renderer and filter documentation is 
                        generated from source code comments using NDoc.</li>
                    <li>100% of public methods are commented in the source code.</li>
                    <li>Reworked the tutorial and howtos</li>
                    <li>Reworked the website.</li>
                </ol>

            </td>
        </tr>
    </table>
</content>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions