Questions tagged [nlog]
NLog is a free logging platform for .NET
2,797
questions
0
votes
0
answers
31
views
How to make .NET 6 Azure Functions V4 work with NLog with dependency injection?
I've been working on this all day and looked at the NLog documentation, StackOverflow, and the NLog GitHub issues. However, there is no real example of how to make Azure Functions V4 work with NLog ...
0
votes
0
answers
16
views
Visual Studio / Nuget puts files in the wrong place
New-ish to ASP.NET Core and VS 2022. Clearly it is doing things differently than previous versions.
I added NLog to my project and everything works great. However, to get the intellisense for the ...
0
votes
1
answer
24
views
Nlog truncate message when condition applies
In my application, I want to log any AMQP-Event published or consumed into two files. The first log-file is my "main"-file which contains various log-statemens from each layer of my ...
0
votes
0
answers
31
views
Use nlog to push logs directly to Grafana Loki Cloud
I have an old WPF app that I want to add some alerting to, so I created a free account in Grafana Cloud and I want to be able to see logs there.
The app is using nlog, so I added a sink in nlog.config ...
0
votes
1
answer
34
views
Custom renderer class doesn’t applies on logs
I have two targets in my nlog.config file
<targets>
<target xsi:type="File"
name="logfile"
fileName="../../../Log/log.log">
<layout xsi:...
0
votes
1
answer
39
views
The correct way to ignore log entries with NLog at runtime
I create a MongoTarget at runtime to the server that's hosting the production database. What's the correct way to ignore unwanted log entries at runtime? I'm currently creating a MemoryTarget and ...
0
votes
1
answer
41
views
How to generate filename from message in NLog
I'm using NLog 5.2.4
My messages looks like this:
[127.0.0.1:50543]: Here comes some text ....
[127.0.0.1:50544]: Here comes some text ....
I want messages to be logged to files with name
test_127.0....
0
votes
1
answer
20
views
NLOG Email Log with Filter not working as expected
Using ASP.NET 4.6.2, NLog version 5.1.2, attempting to log events with a Mail target when certain event properties are set to a boolean true. This does not work. But looks to me like it does work in ...
0
votes
1
answer
24
views
RoslynAnalyzer throws casting errors during build
I'm trying to build NLog in Visual Studio 2019 (Community edition, if that's relevant). NLog is not building due to the casting error below. I've searched the code for the "TypeParameterSymbol&...
0
votes
0
answers
18
views
Global logger variable for dll
I'm working on a C# project in Visual Studio. The project compiles to a DLL, which contains a series of classes, and I'm using Nlog for logging. I'm familiar with setting up the NLog.config to have my ...
0
votes
0
answers
43
views
UseHttpLogging NLOG not writing to file
I have an Asp Net Core 6 application which uses Nlog for logging.
I have it configured to write to a log file and a database, which is working fine.
I have Nlog configured in the appsettings.json file ...
0
votes
1
answer
56
views
What does nlog maxLevel=off config option do when combined with other configuration targeting the same output?
I'm unsure of what the nlog "level=off" config option does when combined with other configuration targeting the same output like the config provided below:
<logger name="Name.Space.*&...
0
votes
2
answers
84
views
Configure NLog and JS Exceptions with Application Insights
I have set up NLog to work with Applicatin Insights and also log js exceptions and is working as required. However, I am struggling with making the instrumentation key dynamic so it targets the ...
0
votes
0
answers
31
views
Configuring NLog using docker container in .NET core API
We are experiencing below issue while using NLog in ASP.NET Core Web API along with Docker container. We didn't face any issues in EC2 with IIS Server. Our ECS LaunchType is fargate.
Error:
Error ...
1
vote
0
answers
59
views
NLog 5.2.4 - Unable to filter out Microsoft.Extensions.Http logs
I am using NLog for logging and I keep getting these logs in my logfile:
2023-09-07 11:45:10.4748 Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler+Log.RequestPipelineStart - 1 - Start ...
-1
votes
0
answers
67
views
System.AggregateException: An error occurred while writing to logger(s). (Input string was not in a correct format.)
This is my middleware class
public HttpLoggingMiddleware(RequestDelegate next, ILogger<HttpLoggingMiddleware> logger)
{
_next = next;
_logger = logger;
_recyclableMemoryStreamManager ...
0
votes
0
answers
36
views
Problem setting different log levels for different namespaces using NLog
I'm having problem getting the nlog configuration correct for a dotnet core 7 application.
The objective is to get logs from Microsoft namespaces to be at the Warn level or higher and all other logs ...
0
votes
1
answer
48
views
Upgrading to NLog 5, two targets cannot log to same file
Is there any way for two NLog targets to write to the same log file in NLog 5? It's possible under NLog 4.6.8 but after upgrading my application to NLog 5 I find it no longer works, at least with the ...
0
votes
1
answer
35
views
How can I integrate a logger (e.g. NLog, log4net, etc.) with the Dynamics CRM 2011 ITracingService?
Context
I spend a lot of time writing custom action (codeactivity class) and occasionally plugins for a Dynamics CRM 2011 on-prem application. All logging in Dynamics is done via the ITracingService ...
0
votes
2
answers
77
views
Prism Unity Register NLog as Microsoft.Extension.Logging.ILogger<T>
I have a shared Code between my backend and my frontend(WPF), where be backend currently uses NReco.Logging.File which is compatible with Microsoft.Extensions.Logging.ILogger.
But in the fronend, I ...
0
votes
1
answer
52
views
How to capture controller name when it actually not controller in nlog .net core?
NLog can capture the controller name and action using {aspnet-mvc-controller} and {aspnet-mvc-action} configuration options, it works fine.
In my case, there is an action that not using a controller ...
1
vote
0
answers
45
views
.net 6 NLog log different namespaces to different log files
I would like to log all events with this namespace: Microsoft.Extensions.* in one log file and all the other events in a different log file.
My nlog config file looks like:
<?xml version="1.0&...
1
vote
1
answer
43
views
How to prevent certain namespaces from being logged using NLog in .NET 6
I am using NLog in .NET 6 and it generates logs a file. I want NLog to skip certain logs. For instance there is a line like this in my file.
2023-08-17 14:00:44
Microsoft.Extensions.Hosting....
0
votes
1
answer
46
views
How to override the built-in JSON formatter / JSON converter in NLog ≥ v5.0?
In our project, we have some class properties that we want to censor when being logged. Each property that is to be censored is attributed with a custom-defined attribute; let's call it ...
0
votes
1
answer
32
views
NLog config in YAML format
I'm using NLog and want to store its configuration in YAML files instead of XML or JSON.
I have the working code (.NET 6) which works with the below YAML, except for the commented-out part.
It uses ...
0
votes
0
answers
25
views
NLog UDP Multicast (or Broadcast)
Can I set NLog target as UDP Network with Multicast or Broadcast? How to?
I tried to find the way in NLog site, but I couldn't.
NLog site
I expected that it can be specific by target attribute like '...
0
votes
1
answer
36
views
NLog generates too many archives
I'm using NLog configured this way:
var logfile = new NLog.Targets.FileTarget("logfile")
{
FileName = Path.Combine(_logDirectory, "myApp.log"),
Layout = "${date} [${...
1
vote
1
answer
41
views
NLog RichTextBoxTarget throws System.NullReferenceException after adding new FileTarget programmatically
My team and I have a Windows Form application which I am converting from .NET Framework 4.6.2 to .NET 6. We are using NLog through Microsoft.Extensions.Logging to write to a log file and a RichTextBox ...
0
votes
2
answers
51
views
How to configure TimestampFormat for MicrosoftConsoleLayout
I'm working on a C# application, using NLog for logging purposes.
I have added an NLog.config file to my application, containing the following layout definition for the console logs:
<target xsi:...
0
votes
0
answers
23
views
How to compile NLog NLog-5.2.2?
In our product we are using Nlog 2.0 version which is quite old and now we trying to upgrade it to Version NLog-5.2.2. but facing build issues.
Can you please suggest/ share steps to follow if any ? ...
0
votes
2
answers
54
views
How to configure NLog for isolated plugin within host application
I'm working on a C# application, using the NLog library.
Log.Info() generates an output, which looks like the following:
2023-07-24 09:04:19.4423 | Info | Company.Customer.Manager.DoSomething | Some ...
0
votes
1
answer
50
views
Nlog in Azure File Share
I am using Nlog in my C# project and i want to save logs in Azure File Share.
I found this nuget and its Github "NLog.Extensions.AzureStorage". https://github.com/JDetmar/NLog.Extensions....
0
votes
1
answer
148
views
NLOG Database Target can't connect
I have an ASP.NET Core 7 web api in which I am attempting to add an NLOG database target. It is definitely not logging and the internal log has provided me with two different messages, depending on ...
0
votes
1
answer
33
views
How roll log file every 10 minutes with NLog
<targets name="GFGLogInfo" xsi:type="BufferingWrapper" bufferSize="2000" flushTimeout="5000" slidingTimeout="false">
<target xsi:...
1
vote
0
answers
31
views
NLog.Targets.Seq and composite formatting
I'm using NLog and Seq together quite successfully, but a third-party library we use makes extensive use of Composite Formatting with message strings like:
"Updated counter via {0} - new value is ...
0
votes
0
answers
26
views
NLog Inserting the Log only first time
I ran into a strange issue with NLog. The code i am using inserts record into the database only the first time LogMigrationInfo() is called. Then it just passes the method, no row is inserted and no ...
2
votes
2
answers
315
views
Write TraceId to logs with nlog
I'm trying to setup my net6 project to send traces and logs to grafana loki and tempo for better observability.
I'm successfully setup sending traces to tempo using opentelemetry.instrumentation(All ...
0
votes
0
answers
76
views
Simplifying NLog JSON Log Messages Sent to Elasticsearch and Kibana in .NET 6.0 Web API
I'm currently working with NLog in my .NET 6.0 Web API project. I have set up NLog to map my logs to Elasticsearch and Kibana. However, I've encountered an issue where each log message includes all ...
0
votes
1
answer
81
views
No Logging via NLog to AzureBlogStorage if single message longer than 638 characters
I loaded the newest version of NLog.Extensions.AzureBlobStorage
<PackageReference Include="NLog.Extensions.AzureBlobStorage" Version="4.2.0" /> in my test project.
Writing ...
1
vote
1
answer
108
views
Can not log {aspnet-request-posted-body} with NLogRequestPostedBodyMiddleware
I try to using ${aspnet-request-post-body} to log the request body in log file, but I got this exception before into controller:
System.NotSupportedException: Specified method is not supported.
at ...
0
votes
0
answers
20
views
NLog global setup of properties
I want to globally setup Logger (NLog) to use it with dependency injection later on with all settings.
I added 2 properties using built-in WithProperty(key, value) method. The problem is that after ...
0
votes
1
answer
119
views
Logging via NLog to AzureBlogStorage for level Info not working
I loaded the newest version of NLog.Extensions.AzureBlobStorage
<PackageReference Include="NLog.Extensions.AzureBlobStorage" Version="4.2.0" /> in my project in .NET Standard ...
0
votes
0
answers
49
views
How do I log key-value pairs using NLog's CsvLayout, using the items' keys as columns?
I have a system that generates a short list of key-value pairs periodically (Dictionary<string, string> basically). The keys are dynamically determined by the application on startup, but after ...
0
votes
1
answer
51
views
.net core published single file spamming "Config reload token fired. Checking for changes..." in log file
At the beginning I am published my .NET core API project to Linux environment. When I using service file execute my WebApplication2.dll, the log is normal without spamming message after started the ...
-1
votes
1
answer
68
views
How to configure output in NDJSON format with NLog
I am working on .NET Framework 4.5.2
NDJSON format I require :
Nlog config in xml format for ndjson format given below
{
"timestamp": "[timestamp]",
"level": &...
0
votes
1
answer
46
views
nlog rules not honored -- writing to my database log
I know there's a bunch in here that's redundant, but out of desperation, trying everything to prevent logging:
My nlog rules section is:
<rules>
<logger name="cfm" minlevel="...
0
votes
0
answers
49
views
Configuring NLog programmatically for a C# DLL
I am trying to port my code over from using SimpleLogger to NLog. And I have a snag list of issues. I have only used NLog once, and when I did it was for a visual Basic console application.
This ...
0
votes
1
answer
111
views
NLog: replace \r\n with actual line break in file
How to make NLog insert actual line breaks to the target file instead of \r\n in ${message}?
I am using a config file to configure NLog as follows:
<?xml version="1.0" encoding="utf-...
0
votes
0
answers
50
views
How to add methodname in logging using runtime reconfiguration
I'm working on a C# application, using NLog for logging purposes.
I have just seen the following in a logfile:
2023-06-08 11:15:58.1816 | NameSpace.ClassName | CheckMATCO | Check CheckFixstation ...
...
0
votes
1
answer
89
views
Symbol \u0000 is rendered many times in logs, generated by NLog
I'm generating logs with NLog's JsonLayout and there are cases where I see such picture on Linux machine:
Why can such things are generated? Seems like there is some problem with JSON generation. ...