Committed to Code

NLog is a free logging platform for .NET with rich log routing and management capabilities. It makes it easy to produce and manage high-quality logs for your application regardless of its size or complexity.

It uses familar logger pattern known from log4xxx. Advanced routing options include buffering, asynchronous logging, load balancing, failover, and more.

This project is managed by Jarek Kowalski.

Project Tags Tagged as dotnet net logging

Code Analysis


News

Using NLog with Mono

After releasing NLog 2.0 a number of people have reported problems with running on latest versions of Mono. Basically at the end of program execution (after the Main() has finished) the program locks up waiting for NLog logs to be flushed, so mono ... [More] process never completes and needs to be killed.

This behavior is only specific to NLog 2.0 – NLog 1.0 did not exhibit this behavior. It seems to be related to threading and timers used by NLog 2.0 which are somehow not available in Mono when the program is about to be terminated. The same code works with .NET just fine. I haven’t fully investigated this issue – maybe Mono folks can see if this issue can be fixed in Mono itself?

Anyway – there is a simple way prevent the deadlock: just make sure you set LogManager.Configuration property to null before your application exits. This will cause Flush() to be executed before Main() finishes and will prevent… [Less]


NLog 2.0 has been released!

It is my great pleasure to announce that NLog 2.0 has been released.

NLog 2.0 release is focused on adding support for new platforms (Silverlight, .NET Framework 4, Windows Phone 7.x), improving logging architecture and manageability and ... [More] addressing most frequently reported user issues.

Binaries can be downloaded from CodePlex.
Sources are available at GitHub.
NuGet packages are also available.

You can read the release notes at http://nlog-project.org/nlog-2-0-release-notes. [Less]


NLog 2.0 Release Candidate is now available

It is our pleasure to announce that the Release Candidate (RC) of NLog 2.0 is now available for download. This is the last milestone before NLog 2.0 final release.

Binary downloads are available on CodePlex
Source code on GitHub
Full ... [More] release notes can be found here.

Please download the release and report any problems you may find. Assuming no critical issues are found, NLog 2.0 will be released within a month from the RC release. [Less]


Exception logging enhancements

One of the frequent feature requests I’ve been getting was to improve the way exceptions are logged. Recent builds of NLog 2.0 include several usability enhancements that should make working with exceptions much easier.

Conditional ... [More] formatting
Conditional logging allows you to make your layouts somewhat more dynamic – you can include/exclude fields based on conditions, provide default values and so on. In order to achieve this, you have 3 new layout renderers at your disposal.

${onexception:INNER} -  output
To render a layout when the exception is being logged, use ${onexception:INNER}, it will output INNER only when current log event includes an exception (in other words when it was emitted using any of the Logger.*Exception() methods. INNER can include other layouts, for example:

<targets>
<target name="f" type="File" layout="${message}${onexception:EXCEPTION OCCURRED\:${exception:format=tostring}}" />
</targets>
It will output log message, but in case of exception, it will also log detailed exception information prefixed with "EXCEPTION OCCURRED:".

${when}… [Less]


Simplifying NLog.Extended.dll usage

I’d like to let you know about small simplification to using targets and layout renderers from NLog.Extended.dll. Previously you had to register them using configuration section:

<extensions>
<add ... [More] assembly="NLog.Extended" />
</extensions>

Starting with today’s Nightly build, this is no longer required – you can simply use extended items without extra registration (exactly like it worked in NLog 1.0). The only change is that you must have NLog.Extended.dll in the same directory as NLog.dll – you will get exception if it’s not present.

If you need NLog.Extended, please give this feature a try and report any issues you find. [Less]


Read all NLog - Advanced .NET Logging articles…

Edit RSS feeds.