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
10
votes
1 answer

How to use NLog in C++?

I have a simple native ++ console application in visual C++. In order to use NLog there is a mixed mode " "NLogC.dll" How can i add "NLogC.dll" to my application And use for logging? Simply how can i use Nlog in a native C++ Application?
Novalis
  • 2,265
  • 6
  • 39
  • 63
10
votes
1 answer

nlog using the connectionStringName for database logging

here is my nlog.config file. I have turned on the throwsException.
eiu165
  • 6,101
  • 10
  • 41
  • 59
10
votes
1 answer

Buffering log messages in NLog and manually flushes them to target

I am trying to log via the NLog MailTarget. It works just fine, but i wanted to wrap the mailtarget with the BufferedTargetWrapper to buffer the log messages until a predefined codepoint, where i want to manually flush the buffer and send the…
dasheddot
  • 2,936
  • 4
  • 26
  • 33
10
votes
3 answers

How can I query the path to an NLog log file?

I've configured a file target for NLog as follows:
aknuds1
  • 65,625
  • 67
  • 195
  • 317
10
votes
4 answers

Nlog fixed file name per app session

I am using Nlog to log from my c# app. The following is the section from my Nlog.config:
meffordm
  • 469
  • 1
  • 6
  • 15
10
votes
1 answer

A sample configuration for nlog and SQL Server Compact 4.0

I would be grateful if someone could post me a sample nlog.config for using nlog with SQL Server Compact 4.0. I can output to the console and a file OK. I've tried various dbProviders and connectionStrings, but nothing seems to work. Thanks in…
Alan T
  • 3,294
  • 6
  • 27
  • 27
10
votes
1 answer

Prevent Microsoft Logging from log when Unhandled exception thrown

I have ASP.NET Core 3.0 website. I installed NLog on the project, here is the configuration public static void Main(string[] args) { var logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger(); …
Hakan Fıstık
  • 16,800
  • 14
  • 110
  • 131
10
votes
2 answers

Log messages from .NET Standard class library

I have a solution with an ASP.NET Core (2.1.5) Web API project which references a couple of .NET Standard 2.0 class libraries projects. I want to implement some logging to my application and I have already done this for the Web API project using…
kreigan
  • 113
  • 1
  • 7
10
votes
1 answer

Linq2DB Nlog or logging

is there a way to log all linq2DB sql queries that are made to he database with NLog? I cannot find any realistic example. There is something for miniprofiler, but this doesn't help me, because I have not experience with it. pull request…
Franki1986
  • 1,320
  • 1
  • 15
  • 40
10
votes
2 answers

Custom NLog target with async writing

NLog allows me to write a custom target. I want to log to my database using Entity Framework Core. In NLog.Targets.Target there is this: protected virtual void Write(LogEventInfo logEvent); However my code is async, so I must do: protected override…
grokky
  • 8,537
  • 20
  • 62
  • 96
10
votes
2 answers

NLog does not flush buffered logs when targets are set as async

I'm currently revising our NLog configurations and while trying to set our targets async and use a BufferingTarget for our mail processsing, I've found that Nlog does not seems to flush the mail on application close. Calling the LogManager.Flush();…
Yannick R.
  • 113
  • 1
  • 11
10
votes
2 answers

Configuring NLog to log exceptions in an XML output?

Currently, we have NLog spitting out CSV files just to prove we have NLog actually logging exceptions.
Corey Ogburn
  • 24,072
  • 31
  • 113
  • 188
10
votes
1 answer

Implementation and usage of logger wrapper for log4net

This question is related to Steven’s answer - here. He proposed a very good logger wrapper. I will paste his code below: public interface ILogger { void Log(LogEntry entry); } public static class LoggerExtensions { public static void…
Tim Laax
  • 149
  • 1
  • 2
  • 12
10
votes
4 answers

NLog auto truncate messages

I'm logging my messages to a database field with a max size of 1000 characters. Currently if I try to log a message (which often contains exception information with stack trace, HTTP request content, etc.) that's larger than 1000 characters, the…
mo.
  • 4,165
  • 3
  • 34
  • 45
10
votes
2 answers

The right way to log to EventLog using NLog

How can I avoid windows-complaining about missing descriptions for event ids when logging using NLog. When I use:
Alexander Schmidt
  • 5,631
  • 4
  • 39
  • 79