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
15
votes
3 answers

How to set NLog max file size?

Is there any option/configuration in NLog to set the max log file size (for example 5MB)? What I need is, that when the log file exceeds the max size (which I define), It will backup the old one (with a time stamp as file name), and start writing to…
zig
  • 4,524
  • 1
  • 24
  • 68
15
votes
4 answers

ASP.NET MVC2 + Ninject + NLog (+ shared hosting?) = NullReferenceException

I have an MVC2 app that's based on the Tekpub Starter Site, so it uses Ninject for dependency injection, NLog for logging, and a bunch of other libraries in various places. As far as I can tell though, it's these that are causing my…
Jon
  • 16,212
  • 8
  • 50
  • 62
15
votes
4 answers

Add current user to NLog output

I want to add a string to each row on my NLog output. The logic stays the same, trying to get the current user and if succeed, add the current user to the output. I know how to implement it each time, but I want to set this template at one place…
Shahar
  • 541
  • 2
  • 7
  • 22
15
votes
9 answers

NLog not working in release mode

I am using NLog to log the exceptions in my asp.net mvc (C#) application. NLog is not working in release mode. The same is working when running in debug mode. What may be the problem? Is there any fix for this?
Prasad
  • 58,881
  • 64
  • 151
  • 199
15
votes
3 answers

NLog configured to automatically log all exceptions?

Is there a way to configure NLog to automatically log all exceptions my application can send? Currently I am going to all TRY/CATCH blocks and manually adding logging in the CATCH - but what if I miss some? And what if in the future someone else…
JSchwartz
  • 2,536
  • 6
  • 32
  • 45
15
votes
3 answers

Should NLog flush all queued messages in the AsyncTargetWrapper when Flush() is called?

I want to shut down my application and write any pending log messages. So I call LogManager.Flush() during my shutdown process. However, I don't see all the messages written out. Instead, if I wait for a few seconds (using Thread.Sleep()) I see the…
ligos
  • 4,256
  • 2
  • 25
  • 34
14
votes
4 answers

NLog internal log not working with ASP.Net MVC

I have a problem with NLog for logging its internal logs with this configuration
JuChom
  • 5,717
  • 5
  • 45
  • 78
14
votes
4 answers

How to use NLog for a DLL

I am trying to implement a simple log using Nlog Refresh 1.0 for a class Library project. It seems nlog does not create a logfile when it's instantiated from within a dll. Is there some other way around this ? my config file looks like this:
Oysio
  • 3,486
  • 6
  • 45
  • 54
14
votes
5 answers

NLog - Write NULL to optional database column

I am using NLog for logging in an ASP.Net application and making use of the database target with Microsoft Sql Server. I have some logging parameters that are optional and not always specified. I would like these to be written as null when they are…
cweston
  • 11,297
  • 19
  • 82
  • 107
14
votes
2 answers

Unable to set my connectionstring in NLog

The NLog.config file does not set the connection string.
arame3333
  • 9,887
  • 26
  • 122
  • 205
14
votes
2 answers

Logging unhandled exceptions using NLog? Should ELMAH and NLog be used together?

I am using ELMAH in my ASP.NET MVC projects and I really like its simplicity. But I needed the ability to log certain events in my code in a log.Info("message") manner. Since ELMAH does not provide that ability I started looking at NLog. A few…
Thomas
  • 5,888
  • 7
  • 44
  • 83
14
votes
2 answers

NLog limit size of daily archive

I'm using NLog logging framework. My application needs to keep archive of last 14 days of logs. The current NLog.config that I use looks like this.
John Titor
  • 381
  • 1
  • 3
  • 13
14
votes
2 answers

Where do I see log entries in Application Insights?

I got Application Insights up and running for my ASP.NET application. Then, I installed Microsoft.ApplicationInsights.NLogTarget package and added ApplicationInsightsTarget to my NLog configuration. It seems to be working fine. At least I can see…
UserControl
  • 14,766
  • 20
  • 100
  • 187
14
votes
2 answers

How to log to multiple targets using NLog?

I am using NLog and I want to log to RichTextBox and File at the same time. And I want to configure the Logger programmatically, not with xml config file. The following code only logs to the last target (File in this case). Can anybody…
Imran S.
  • 935
  • 3
  • 15
  • 32
14
votes
1 answer

NLog: can't write to event log

I can't write to the event log with NLog. I've been able to write to the console and to a file. I've turned on exceptions in NLog and am receiving no feedback from NLog. Here is my NLog.config:
sparks
  • 1,264
  • 1
  • 15
  • 29