Vote or submit ideas on UserEcho!
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 can process diagnostic messages emitted from any .NET language, augment them with contextual information, format them according to your preference and send them to one or more targets such as file or database.
For more information, see the website nlog-project.org or just get started with the tutorials on the NLog wiki.
Project news - including RSS feed
Packages & Status
NLog consists of multiple packages. Most of the functionality is inside the NLog (core) package. What's inside the packages? See targets and layout renderers overview!
Package | Build status | NuGet |
-------- | :------------ | :------------ | :------------------
NLog (.Net / Silverlight 4+5 / Xamarin iOS / Xamarin Android / Windows Phone 8) | |
|
NLog (CoreCLR) |
|
|
NLog (ASP.NET 5) |
|
|
NLog (Mono) |
| |
NLog.Config |
|
|
NLog.Contrib.ActiveMQ |
|
|
NLog.Extended |
|
|
NLog.Elmah |
|
|
NLog.Etw |
|
|
NLog.InstallNLogConfig |
|
|
NLog.ManualFlush |
|
|
NLog.Schema |
|
|
NLog.Web |
|
|
NLog.Web for ASP.NET 5 |
|
|
NLog.Windows.Forms |
|
|
NLog.Owin.Logging |
|
|
Questions, bug reports or feature requests?
Do you have feature requests, questions or would you like to report a bug? Please post them on the issue list and follow these guidelines. Please also post or vote features requests on UserEcho.
Frequently Asked Questions (FAQ)
- What is NLog?
- NLog is a free and open source library which helps to write log messages.
-
Why should I use a log libary? I can just do
file.WriteLine()
- Beside writing to files, you can write to many different targets, like databases, event viewer, trace etc.
- The output is templatable with many predefined template values.
- With a simple configuration file you can decide runtime (after deployment), what to log and where! No need to restart the program or recyle the app pool!
-
Why should I use NLog?
- NLog is fully written in C#, has many years of experience and is easy to extend!
-
Is it free?
- It's licensed under the BSD license, so you can use it in commercial (closed sourse) programs without problems.
-
Show me the magic!
- Check the tutorial to get started!
-
I can't see anything?!
- NLog not working as expected? Check the troubleshooting guide. If you think it's a bug, please check contributing.md and create a GitHub issue!
-
I'm missing important stuff!
- You can send a feature request, but do you know you can extend NLog with a few lines of code?
-
How do I upgrade to NLog 4.x?
- Check the 4.0 release post, there are some breaking changes.
- Update all the NLog packages. The latest stable version is recommend.
- When upgrading from NLog 4.1.0, please the next question.
-
I have trouble updating NLog from 4.1.0
- We take semver very serious! Because NLog is strong named, it's important to keep the assembly version of all major versions the same, otherwise every library build on 4.0.0 should be reompiled for every other 4.x release (4.1, 4.2 etc) - which is unwanted because of semver.
In NLog 4.1.0 there was a mistake in the assembly version, which has been fixed in 4.1.1. Upgrading from NLog 4.1.0 to another version can give issues when using NuGet. This will result in the following error:
Could not load file or assembly 'NLog' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
If you upgrade, remove or alter the
<assemblybinding>
, as explained at the 4.1.1 news post. - We take semver very serious! Because NLog is strong named, it's important to keep the assembly version of all major versions the same, otherwise every library build on 4.0.0 should be reompiled for every other 4.x release (4.1, 4.2 etc) - which is unwanted because of semver.
-
Should I use Common Logging?
-
That's up to you. It has it pros and cons. The greatest advantage is that you can easily switch between logging implementations (NLog, Log4Net, EntLib). This can be very important if you’re writing a library yourself, then the user who's using your library can choose which implementation to use.
-
There are some downsides:
- You are limited in some features, or some features aren't available at all (like context classes or event properties)
- The performance is a bit lower.
- The platform support is lower. For example, there is no Xamarin support or a specialized .Net 4.5 build
- The progress is limited by NLog and Common logging.
-
-
Which Common Logging version should I use?
- As you may have noticed the latest version of Common Logging doesn't match the latest version of NLog - the latest Common Logging is build to NLog 4.1. But that is not a problem! Since NLog 4.0 the assembly version is fixed to
4.0.0.0
and because follow semver, you can use the latest version of NLog with Common.Logging.NLog41.
- As you may have noticed the latest version of Common Logging doesn't match the latest version of NLog - the latest Common Logging is build to NLog 4.1. But that is not a problem! Since NLog 4.0 the assembly version is fixed to
-
I'm writing a library who's using NLog. Should I update when NLog has an update?
- If you don't use the latest additions, then you should only update every NLog major version. As mentioned at the Common Logging version, we will keep the assembly version fixed. The end-user don't need
<assemblybinding>
-magic! So in short: your library should target NLog 4.0 and in the future NLog 5.0.
- If you don't use the latest additions, then you should only update every NLog major version. As mentioned at the Common Logging version, we will keep the assembly version fixed. The end-user don't need
Contributing
As the current NLog team is a small team, we cannot fix every bug or implement every feature on our own. So contributions are really appreciated!
If you like to start with a small task, then up-for-grabs are nice to start with.
A good way to get started (flow)
- Fork the NLog repos.
- Create a new branch in you current repos from the 'master' branch.
- 'Check out' the code with Git or GitHub Desktop
- Check contributing.md
- push commits and create a Pull Request (PR) to NLog
License
NLog is open source software, licensed under the terms of BSD license. See LICENSE.txt for details.
How to build
Use Visual studio 2012/2013/2015 and open solution file in the 'src' folder, like 'NLog.netfx45.sln'
For building in the cloud we use:
- AppVeyor for Windows builds, including Silverlight and Xamarin.
- Travis for Mono builds.
- CodeCov for code coverage
How to build your fork in the cloud
Steps to set up AppVeyor/Travis/CodeCov for your own fork.
AppVeyor:
- Login with your Github account to https://ci.appveyor.com
- Choose "projects"
- Select your fork and press "+" button
- Done. All config is in appveyor.yml already
Travis:
- Login with your Github account to https://travis-ci.org/
- Select your fork
- Push and wait
CodeCov: (AppVeyor needed)
- Login with your Github account to https://codecov.io/
- Press "+ Add new repository to Codecov" button
- Select your fork
- Wait for a build on AppVeyor. All the config is already in appveyor.yml. The first report can take some minutes after the first build.