Questions tagged [nlog-configuration]
28 questions
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
22
votes
2 answers
Have NLog write to console
I'm pretty new to NLog. I have a .NET framework console application using NLog. I hope to configure NLog to write the log to console directly. I installed NLog and the NLog.Config NuGet package, with the following content in nlog.config:

checai
- 836
- 4
- 11
- 17
22
votes
5 answers
make NLog.config file load the file from (d:\dev) instead of "\bin\debug\"
I used Nlog for logging purpose in a particular DLL. The DLL is then used in another application (it is loaded dynamically using System.Reflection.Assembly.LoadFrom(path + a.dll)). I manually placed Nlog.dll and Nlog.config files in Path folder and…

rookie_developer
- 1,359
- 3
- 15
- 27
8
votes
1 answer
NLogConfigurationException - Invalid cast from 'System.String' to 'System.Uri'
Nlog is throwing an exception now that I have updated from 1.0 -> 2.0.
When NLog.Config.XmlLoggingConfiguration.Initialize is called the following exception occurs:
"Error when setting property 'Url' on WebService…

Gent
- 2,675
- 1
- 24
- 34
8
votes
3 answers
How to apply different layouts to the same target in NLog?
NLog allows me to use SplitGroup to log my messages to several targets. I'd like to use this feature to log each message to a common, user-specific and date-specific logs at once:

Dan Abramov
- 264,556
- 84
- 409
- 511
5
votes
1 answer
Logging datetime with ms precision using NLog event context layout renderer
I am trying to log some audit information to a SQL Server 2008 table using NLog 2. In order to be able to pass parameters to the SQL insert query, I'm using LogEventInfo and the Event Context Layout Renderer.
The logging itself works but the…

james.christou
- 53
- 1
- 5
4
votes
1 answer
Nlog with a class Library
I have a class library and configuration file in a separate place I want to use it
so I do the following
LogManager.Configuration = new NLog.Config.XmlLoggingConfiguration(configurationFile , true);
LogManager.ReconfigExistingLoggers();
The…

Ali
- 1,975
- 5
- 36
- 55
4
votes
4 answers
What is the best way to centralize logging with NLog?
I have been assigned a project with a lot of poorly written code that is based around SharePoint.
It consists of about 15 subprojects, some of them being windows services, some web services, some web applications running inside of SharePoint, some…

Dan Abramov
- 264,556
- 84
- 409
- 511
3
votes
1 answer
NLog config rule not taking affect
I have the following nlog.config file for my project. When I debug locally, it works as expected, that Hangfire messages are being filtered to only show Warn and above. However on our staging server (IIS 8.5) nlog seems to ignore the rule and just…

benpage
- 4,418
- 3
- 41
- 39
2
votes
1 answer
Why do I get FormatException with NLog?
I get the fllowing in the internal NLog log :
2020-05-10 16:38:09.9251 Warn Error when formatting a message. Exception: System.FormatException: The input string had an incorrect format.
vid System.Text.StringBuilder.FormatError()
vid…

Banshee
- 15,376
- 38
- 128
- 219
2
votes
1 answer
NLog LogEventInfo to log exception
I am using the LogEventInfo to log both to a log file and database entry. I also want to log the stacktrace when exception is thrown to the log file. I thought I just need to set the Exception property in the LogEventInfo to the exception I want to…

Helic
- 907
- 1
- 10
- 25
1
vote
1 answer
NLog configuration from both code and config file
I have NLog code currently reading from NLog.config to set up logging to text files and then I'd like to add logging fatal errors to email. However, the email settings are in my appsettings.json file.
What I tried so far is this in my Startup.cs
var…

Mark Cilia Vincenti
- 1,410
- 8
- 25
1
vote
1 answer
Enabled attribute is not declared in nlog rule

Mhd
- 771
- 1
- 8
- 15
1
vote
1 answer
NLog: Why BufferingWrapper does not seem to buffer log entries
I have a simple .Net core (2.2) Console application.
I am trying to configure it to work with NLog.
For simplicity, I am using "File" target.
I am trying to configure Buffering Wrapper so I wrapped the target as follows:

ram dvash
- 190
- 1
- 11
1
vote
1 answer
How to specify a default path for a File Target when a given event-property is not present?
I have a File Target as follow:
This file target logs the entries of each employee in a separate file based on the…

KeyBored
- 601
- 4
- 14