Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use NLog from multiple projects in the same solution

I searched the net for a really simple question. My solution is one exe (WPF) project and four class libraries. I need a logging and I like NLog. How can I use it from all of the 5 projects in one solution ?

I don't know, do I need to create (or get somewhere) a wrapper class project referenced from all of the projects and use Nlog from there ? I saw something like this written for log4Net.

Or is there some pattern or best practice for this scenario ?

like image 800
sinkien Avatar asked Mar 21 '15 22:03

sinkien


People also ask

How do you integrate NLog?

Adding NLog NuGet Package As a first step we need to install NLog from NuGet package manager. To do this, right click the Project from Solution Explorer and select Manage NuGet Packages from the context menu. It will open the Package Manager Solution window. From the Package Manager window, browse for NLog.

Does NLog create directory?

NLog don't create directories for logs #3066.

What is target NLog?

Targets - the destinations of a logevent, e.g. file, database, console. Layout - the layout e.g. json, csv, plain-text (default)


Video Answer


1 Answers

Just reference NLOG directly in each of the projects and use it. But you only need to configure it in your main application. The configuration will then be shared automatically.

like image 194
Mike Parkhill Avatar answered Sep 21 '22 13:09

Mike Parkhill