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
12
votes
5 answers

serialize objects or collections to log

I want save some addtitional info with my error message. For example it should be user query, or something else. How should I do it? Is there any build it methods for logging collections, structurest or objects? Or I should serialize it myself?
Yavanosta
  • 1,480
  • 3
  • 18
  • 27
12
votes
3 answers

Setting up C# solution with multiple projects using NLog in Visual Studio

My solution in Visual Studio 2012 currently contains two projects: DLL WPF application (which requires methods of the DLL) Both, the DLL and the WPF application, use NLog for logging. Currently each project contains the NLog DLL itself. Here is…
Robert Strauch
  • 12,055
  • 24
  • 120
  • 192
12
votes
1 answer

log LINQ-to-SQL generated SQL to NLog

I would like to use NLog to output my LINQ to SQL generated SQL to the log file e.g. db.Log = Console.Out reports the generated SQL to the console,…
Coppermill
  • 6,676
  • 14
  • 67
  • 92
12
votes
3 answers

NLog.config intellisense not working

I get the following error: The global element 'http://www.nlog-project.org/schemas/NLog.xsd:nlog' has already been declared. And a lot of the following errors with different types: The complexType …
david.s
  • 11,283
  • 6
  • 50
  • 82
12
votes
4 answers

Cannot load Exchange powershell snap-in: The type initializer for 'Microsoft.Exchange.Data.Directory.Globals' threw an exception

I have the following code that creates a PowerShell runspace with the Exchange 2010 snap in loaded. Dim runspaceConfig = RunspaceConfiguration.Create() Dim snapInException As PSSnapInException =…
11
votes
4 answers

Logging on .net MAUI

.net MAUI recently removed logging in one of it's newest release. What is the alternative now and how should it be implemented? Have been going all over online, but couldn't find a single example of any logging architecture implemented. Tried…
11
votes
2 answers

Manage logging configuration with NLog in .NET Core 3

I'm using NLog in a .NET Core 3.1 worker service application. Following the tutorial of NLog I inserted an nlog.config file to manage the configuration. Now I'm confused because I have three points where I configure the logging: In the code where I…
Tonyc
  • 709
  • 1
  • 10
  • 29
11
votes
2 answers

Nlog and Custom Levels

i know there are some log levels builtin in NLog like trace, info, fatal etc i want to define some new ones such as "DBLog" and be able to only configure all logs with DBlog to be targeted to a certain Target. is there is a way to do that ? or i…
Stacker
  • 8,157
  • 18
  • 73
  • 135
11
votes
5 answers

How to Log to Elastic Search by NLog or SeriLog with authentications

We are currently use azure scale set (many VMs on one source group with load balance and one availability set), we used to use NLog to log our web app action and errors, but now we asked/needs to use Elastic Search and also use centralized log for…
Bashar Abu Shamaa
  • 1,998
  • 2
  • 21
  • 36
11
votes
2 answers

Change basedir in NLog Targets in runtime programmatically

I have Windows Forms app NET 4.5 (VS 2013) using NLog. I have targets:
Kiquenet
  • 14,494
  • 35
  • 148
  • 243
11
votes
4 answers

How to configure NLog to get IP address .NET Core

I develop .net core app and use NLog as logging framework. How can I setup NLog layout to get remote IP address? Unfortunately, ${aspnet-request.serverVariable=remote_addr} isn't supported by NLog.Web.AspNetCore. May be I can get access to…
A. Gladkiy
  • 3,134
  • 5
  • 38
  • 82
11
votes
3 answers

NLog dynamically change filename using NLog.config

How to dynamically change the FileName using a variable from C#? My idea is to create a log file like Log__${date:format=yyyy-MM-dd}.log. Any ideas?
gjfonte
  • 488
  • 2
  • 4
  • 15
11
votes
1 answer

What is the purpose of NLog LogManager.GetLogger(String, Type) overload

LogManager class has two methods: GetLogger and GetCurrentClassLogger, with an overload taking parameter Type loggerType public static Logger GetLogger(string name, Type loggerType) public static Logger GetCurrentClassLogger(Type…
Ilya
  • 21,871
  • 8
  • 73
  • 92
11
votes
1 answer

why is CONVERT string to VARBINARY in SQL Server only converting first character?

I am using NLog to log in my application and as part of that we are logging the customer number, which is a string in C#, and a varbinary(32) in the database. I am using the following SQL code for this specific parameter. The rest of the SQL…
ClaytonHunt
  • 533
  • 1
  • 7
  • 19
10
votes
2 answers

How can I unsubscribe a NLog target

I want a NLog target to stop listening to the log. The RemoveTarget method doesn't seem to work. Here is a failing test. public class when_stopping_to_listen { static Logger Logger; static MemoryTarget target; Establish context = () => …
forki23
  • 2,784
  • 1
  • 28
  • 42