Questions tagged [nlog]

NLog is a free logging platform for .NET

NLog is a logging platform for .NET with support for structured logging. NLog enables easy routing and filtering of output to various targets.

Resources

2784 questions
14
votes
1 answer

AspNetSession layout renderer not working

I am using NLog for logging in my asp.net 4.5 website. I have used NLog 4.0. Now I need to use session variables in my logs. So i tries to use AspNetSession layout renderer. This layout renderer is included in Nlog.Web. I have added this dll and…
Deeps
  • 557
  • 9
  • 31
14
votes
1 answer

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…
sinkien
  • 289
  • 1
  • 3
  • 11
14
votes
1 answer

How to force NLog to overwrite the log file

I need NLog to overwrite the log file when the application is restarted. Currently it appends to existing file. For example I have something like this in my NLog.config
Vadim
  • 21,044
  • 18
  • 65
  • 101
14
votes
3 answers

Automatically log System.diagnostics.trace messages to an Nlog target

Say you have C# trace messages all over an application. Something like: Trace.TraceInformation("Service Started"); How do you automatically log this to an nLog target without having to add code like the following to all the classes that…
Solracnapod
  • 843
  • 3
  • 13
  • 23
13
votes
3 answers

How to tell NLog to log exceptions?

Target: When I call Logger.Error("some message", e), where e is some…
Andrey
  • 20,487
  • 26
  • 108
  • 176
13
votes
4 answers

C# derived class type needed in base for logging using NLog

We're using NLog for logging in an C# MVC3 web application. All of our controllers extend a custom base "ApplicationController" that gives us access to a constantly needed methodes and s members. I'd like all controllers to have access to the…
Bobby B
  • 2,372
  • 3
  • 24
  • 31
13
votes
2 answers

NLog config file to get configuration setting values from a web.config

Is there a method to get a value from the section of a web.config within NLog layout variables? I already store SMTP details within my web.config and don't want to duplicate the settings just to use within my…
Dave Hogan
  • 3,201
  • 6
  • 29
  • 54
13
votes
2 answers

ILogger not writing TRACE and DEBUG messages to target

I'm working on setting up some logging in our ASP.NET Core 3 application, using ILogger (Microsoft.Extensions.Logging) with NLog to enable writing to text files. The problem is, that the ILogger does not write TRACE and DEBUG level messages. Either…
RonRonDK
  • 425
  • 6
  • 22
13
votes
2 answers

NLog not logging on all levels

ASPNET Core 2.0 with latest Nlog. All config files load correctly. My config file is simple, I just want it to log every thing.
Piotr Kula
  • 9,597
  • 8
  • 59
  • 85
13
votes
2 answers

Does ASP.NET Core's built-in logging make NLog/Serilog/etc obsolete?

We use NLog or Serilog to do logging. We're busy porting a system from ASP.NET to ASP.NET Core, which has logging built in. Ideally, we'd like to drop NLog, as there doesn't appear to be a need for it anymore. However, is the built in logging…
grokky
  • 8,537
  • 20
  • 62
  • 96
13
votes
2 answers

LogManager.configuration is null

I've added NLog using nuget to a project and added NLog.config. I'm running the debugger and getting a NullReferenceException due to the fact LogManager.Configuration is null: LogManager.Configuration.AddTarget("sentinel", sentinalTarget); This…
P.Brian.Mackey
  • 43,228
  • 68
  • 238
  • 348
12
votes
2 answers

Ninject.Extensions.Logging.nlog2 - How to?

Browsing the nuget library, i came across Ninject.Extensions.Logging.nlog2. Some googling and trying to figure things out, I can't seem to find how or why you would use this extension. Is it advisable to use with MVC 3? What exactly is the…
Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291
12
votes
1 answer

Entity Framework logs duplicates

We're running Entity Framework 6 and have a DatabaseLogFormatter that formats our data, and it's logged via an NLog AsyncTargetWrapper to a file. The application is an MVC5 web app. The DatabaseLogFormatter is mostly empty stubs, except LogCommand…
muddymess
  • 303
  • 2
  • 12
12
votes
1 answer

NLog GetCurrentClassLogger() NullReferenceException using StructureMap (Full Trust)

It seems like NLog can't use reflection for GetCurrentClassLogger(), even though my MVC 3 app is deployed in a Full Trust environment on IIS7. I'm using StructureMap 2.6.1 and the problem seems to appear sporadically between deploys. I can't figure…
Petrus Theron
  • 27,855
  • 36
  • 153
  • 287
12
votes
2 answers

NLog Inner Exception Logging

I'm trying to log inner exception messages by using NLog. This is a piece of my NLog.config file:
Luis Teijon
  • 4,769
  • 7
  • 36
  • 57