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

How to make Nlog archive a file with the date when the logging took place

We are using Nlog as our logging framework and I cannot find a way to archive files the way I want. I would like to have the date of when the logging took place in the logging file name. Ex All logging that happend from 2009-10-01 00:00 ->…
Carl Bergquist
  • 3,894
  • 2
  • 25
  • 42
30
votes
6 answers

How Thread-Safe is NLog?

Well, I have waited for days before deciding to post this issue, as I was not sure how to state this, resutling into a long detailed post. However, I think it is relevant to ask for the community's help at this point. Basically, I tried to use NLog…
Mehdi LAMRANI
  • 11,289
  • 14
  • 88
  • 130
30
votes
1 answer

Adding method name in NLog

I am using NLog and following the recommended pattern of having a log declare on each class, for the purpose of being able to track which class/method has written to the log. I do find this very useful to have a bit of a top level 'stack trace' with…
dferraro
  • 6,357
  • 11
  • 46
  • 69
30
votes
2 answers

NLog: Format loglevel with Whitespaces

I am using NLog for logging. Currently my Layout-String is: "${date:format=dd.MM.yyyy HH\\:mm\\:ss,fff} | ${level:uppercase=true} | ${message}" This results in the following Logs: 18.12.2013 11:23:14,834 | INFO | this is an info 18.12.2013…
user3114804
  • 303
  • 3
  • 4
30
votes
4 answers

How do I configure NLog to write to a database?

I'm trying to get NLog to write to a database, however with my current code it throws an exception when I attempt to debug, the exception is: The type initializer for 'NotifyIcon.Program' threw an exception. my NLog configuration file code is below,…
Captain_Custard
  • 1,308
  • 6
  • 21
  • 35
30
votes
8 answers

How do you log errors (Exceptions) in your ASP.NET apps?

I'm looking for the best way to log errors in an ASP.NET application. I want to be able to receive emails when errors occurs in my application, with detailed information about the Exception and the current Request. In my company we used to have our…
Costo
  • 5,940
  • 8
  • 33
  • 35
30
votes
1 answer

Nlog not creating file relative to website project

I am using a website project, I added Nlog from Nuget, and used the following NLog configuration :
FarFigNewton
  • 7,108
  • 13
  • 50
  • 77
29
votes
1 answer

How to configure NLog to only log from a certain level for a logger namespace for *all* targets

I have the following loggers configured.
Ramon Smits
  • 2,482
  • 1
  • 18
  • 20
29
votes
3 answers

NLog - delete logs older than X days

How I can delete files with logs older than X days. It's simple, but I have in one folder logs only from one day. My NLog.config looks like:
piotrbalut
  • 857
  • 1
  • 9
  • 21
28
votes
4 answers

NLog configuration in appsettings.json instead of nlog.config in .NET Core

The NLog documentation explains how to configure NLog for .NET Core applications by using an nlog.config XML file. However, I'd prefer to have just one configuration file for my application - appsettings.json. For .NET Framework apps, it's possible…
AlliterativeAlice
  • 11,841
  • 9
  • 52
  • 69
28
votes
1 answer

What is the difference between log4net.ThreadContext and log4net.LogicalThreadContext?

UPDATED on 11/18/2014 - While browsing the log4net source repository, I found that the implementation of LogicalThreadContext was modified in November 2011 to that it stores its properties using CallContext.LogicalSetData (and gets them using…
wageoghe
  • 27,390
  • 13
  • 88
  • 116
28
votes
1 answer

Is there a way to put NLog.config information inside of my app.config file?

Is there a way to put NLog.config information inside of my app.config file? This way I can have one config file instead of two. It could look like this:
user2023861
  • 8,030
  • 9
  • 57
  • 86
28
votes
1 answer

Only send one email with all the errors using NLog with Console Application using C#

I want to send only one email with all the errors I get from my C# Console Application. I have the Targets:
Patrick
  • 2,995
  • 14
  • 64
  • 125
28
votes
4 answers

How to create new log file for each application run

As the title implies how can I create a new log file for each application run ? I know how to do it for minute/hour/etc. but not for app. run There is what I have for now: target name="Debug"…
invis
  • 1,078
  • 2
  • 14
  • 26
27
votes
7 answers

Update NLog target filename at runtime

In my application, I work on several thousand of document a day. I'd like, in some cases some logs, one log by document. Then I'd like for a specific target change the output filename (and only the filename) at runtime. Around the web I found how to…
TheBoubou
  • 19,487
  • 54
  • 148
  • 236