Nlog Callsite is wrong when wrapper is used

See my answer to this question: Problem matching specific NLog logger name I have copied the example code (for an abbreviated NLog wrapper) from that answer here to save some trouble: class NLogLogger : ILogger { private NLog.Logger logger; //The Type that is passed in is ultimately the type of the current object that //Ninject … Read more

Microsoft.Extensions.Logging Vs. NLog

With NLog you could do: var logger = NLog.LogManager.GetCurrentClassLogger(); logger.Info(“Hello {Name}”, “Earth”); That works for all platforms and all frameworks. Microsoft.Extensions.Logging With .NET Core, Microsoft introduced the ILogger abstraction from Microsoft.Extensions.Logging. You could use that logging abstraction in your project and integrate it with NLog. For example in ASP.NET Core you could inject Microsoft.Extensions.Logging.ILogger<HomeController> and … Read more

How Thread-Safe is NLog?

I don’t really have an answer to your problem, but I do have some observations and some questions: According to your code, it looks like you want to create a logger per thread and you want to have that logger log to a file named for some passed-in id value. So, the logger whose id … Read more

Use NLog in ASP.NET Core application

For ASP.NET Core, you need NLog.Web.AspNetCore – which has a dependency on NLog.Extensions.Logging. Note: Microsoft.Framework.Logging.NLog has been replaced by NLog.Extensions.Logging on NuGet, which is maintained by the NLog team. How to use: Setup NLog needs to be enabled so it will integrate into the DI and log API of ASP.NET Core. This will result that … Read more

log4net vs. Nlog

I was recently tasked to “prototype up some loggin’” for an upcoming project. I didn’t have any logging framework experience. I researched, ran through tutorials, made toy apps, etc. on Log4Net, NLog, and Enterprise Library for a few days. Came back 3-4 weeks later and put them together into a cohesive demo. Hopefully some of … Read more

Most useful NLog configurations [closed]

Some of these fall into the category of general NLog (or logging) tips rather than strictly configuration suggestions. Here are some general logging links from here at SO (you might have seen some or all of these already): log4net vs. Nlog Logging best practices What’s the point of a logging facade? Why do loggers recommend … Read more

Logger wrapper best practice

I used to use logging facades such as Common.Logging (even to hide my own CuttingEdge.Logging library), but nowadays I use the Dependency Injection pattern. This allows me to hide loggers behind an application-defined abstraction that adheres to both Dependency Inversion Principle and the Interface Segregation Principle (ISP) because it has one member and because the … Read more