2,906 questions
0
votes
1
answer
60
views
NLog.Web.AspNetCore not formatting object as JSON
I'm trying to log error objects as JSON in my ASP.NET Core 9 Web API. I am following the wiki in the NLog documentation: Structured logging.
I have NLog.Web.AspNetCore v6.0.5 as a dependency. In ...
0
votes
1
answer
52
views
Is it possible to log ApplicationBuilder configuration failure?
I'm using NLog with ApplicationBuilder. The problem is that application startup failure is not captured with NLog. Is there something I can do with it, or should I report this to MS?
Here is the ...
1
vote
0
answers
125
views
NLog does not archive the file
In my WCF / C# project, I am using Nlog, it successfully creates logs inside the current date folder, but it does not archive the log files.
NLog.config:
<nlog xmlns="http://www.nlog-project....
0
votes
0
answers
68
views
NLog not creating log file on user machine
NLog doesn't create one text log file (specific log) on a user's machine although it does create a different text log file (catch-all log) in the same folder.
Here's the config:
<targets>
&...
1
vote
1
answer
132
views
Using ILogger and Message Templates how does NLog decide date/time format for output?
As part of converting a custom logging solution to ILogger using NLog to output the data, I'm looking at how the "${message}" is generated.
I know for most types, the ToString is used to ...
0
votes
1
answer
59
views
How can I change nlog logging level based on event properties
I have created a custom event property in my logging, to categorise different logs from different areas. I want to be able to set a default logging level of Info, but then increase the logging level ...
0
votes
0
answers
40
views
Blazor Server, Nlog ScopeContext - property propagation to all components and services
In my Blazor Server app I have LoggingCircuitHandler:
public sealed class LoggingCircuitHandler
: CircuitHandler
{
private readonly ILogger<LoggingCircuitHandler> _logger;
private ...
0
votes
1
answer
62
views
Custom NLog Layout Render with support of inner layout
I'm trying to map predefined Elastic Search indices with ASP environment variable value with the following custom layout render:
[LayoutRenderer("elk-environment-index")]
public ...
-2
votes
1
answer
61
views
Wrong ClassName in Logging [closed]
Some time ago I injected NLogs for ILogger see the link bellow.
Prism Unity Register NLog as Microsoft.Extension.Logging.ILogger<T>
No some time after I recongnized that the Classname is wrong. ...
0
votes
1
answer
106
views
Nlog.config - logging http context related data into app-log.txt from background process
I had a problem with logger invoked from Quartz
<target name="logfile" xsi:type="AsyncWrapper">
<target name="logfileInternal" xsi:type="File" ...
1
vote
0
answers
63
views
Logging to SEQ from NLOG while making the seq url variable configurable in nlog.config
I tried many things, both programatically and via nlog.config, and none of it works:
<variable name="sequri" value="${environment:variable=SeqUri}" />
<target
...
0
votes
1
answer
91
views
Limit argument length in console output while keeping full length in log files using NLog
I have configured NLog (5.3.4) in my ASP.NET Core project (.NET 5.0) and am using ILogger from Microsoft.Extensions.Logging which is injected through DI. Now I'm logging messages with parameters like ...
0
votes
0
answers
49
views
TransactionalMSMQ target in Nlog.config file is not pushing messages to the queue when upgraded NLog to 5.4 from 4.6.4
I am working on a .Net project where i use Logger from Microsoft.Extensions.Logging to log the errors to be seen in event viewer as well as to push the messages to the MSMQ.
When i had nuget package ...
1
vote
0
answers
118
views
Logging from .NET Maui to iOS not working using NLog.Targets.MauiLog
I'm writing a Maui app in Visual Studio, primarily for iOS, and I want to implement logging.
I've set up NLog.Targets.MauiLog based on the readme here: https://github.com/NLog/NLog.Targets.MauiLog
...
0
votes
0
answers
199
views
Logging system does not work (Nlog) in C# Windows Forms app
I am developing a Windows Forms app with C# and I want to add logging to it. I add NLog package to my project.
This is my Nlog.config file:
<?xml version="1.0" encoding="utf-8" ?...
0
votes
2
answers
67
views
How to override an NLog rule while using include feature?
I have a process with this NLog config (I edited file path for convenience):
Using NLog 5.3.4.
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-...
0
votes
0
answers
46
views
NLog SEQ Log-Target throws exception about forcibly closed connection
We're using Seq as a central log server for our microservices.
Services are written in C# using NLog for structured logging.
NuGet packages (all in current version)
NLog
NLog.Extensions.Logging
NLog....
0
votes
2
answers
67
views
Using 2 different configured NLog Loggers with Microsoft.Extensions.ILogger and Dependency Injection
I want to use 2 different configured NLog Loggers (one should log to a Database, the other to console) in a Blazor Server App and use them both in my services as individual objects using Microsoft....
0
votes
1
answer
81
views
How to avoid 'Access to the path...denied' logging to file on Android with .NET Maui
I've started developing with .NET Maui. I'm still learning. One of the early things I did was to get Nlog logging to a file with an Android phone. Now I'm getting System.AggregateException: 'One or ...
1
vote
1
answer
114
views
NLog filter logging output from System.Net.Http.HttpClient
I have messages in my logs like this
2025-03-07 14:47:38.7205 INFO System.Net.Http.HttpClient.signed.LogicalHandler Start processing HTTP request POST http://localhost:5000/api/KATA/scans?...
0
votes
1
answer
67
views
A logger with filter not working in 4.75 but it does in 5.0
I have the following configuration:
<logger name="*" minlevel="Debug" writeTo="jobFile" >
<filters default-action="Ignore">
<when ...
-1
votes
3
answers
383
views
Why does my `NLog` logging command not log anything (despite NLog.config)?
I'm using NLog library for logging purposes.
I have declared the following class:
public partial class FenetrePrincipale : Form
{
#region NLog
private static readonly Logger logger = ...
0
votes
1
answer
59
views
ASP.NET Core 8: error controller method catches the error code, but does not display requested view
I'm using NLog so that when server gets error will direct action to ErrorController.
Program.cs:
app.UseStatusCodePagesWithReExecute("/Error/{0}");
app.UseExceptionHandler("/Error"...
0
votes
1
answer
59
views
Customize threadName in .NET when using NLog
I'm currently using NLog to log out the threadName, but to use the threadId when there is no name.
This has worked well for a long time using the following format
${threadname:whenEmpty=${threadid}}
...
1
vote
0
answers
119
views
Corrupted logged strings
I have a C# .NET 6 console application that use many threads (let's say 15-30) with a shared logger instance. After many hours of work (one day or more) logged strings become corrupted as:
[2024-11-...
1
vote
1
answer
150
views
Is Adaptive Sampling Disabled/Enabled by default by the application side on .NET Console App?
When we send Log To Application Insight using Telemetry Configuration and New TelemetryClient with CustomTelemetryInitializer Not using ApplicationInsight SDK Or Worker Service for a Console App.
Just ...
0
votes
1
answer
76
views
Merge property values with NLog
I usually use structured logging with NLog for my projects. If I use the same name of context, scoped and inline properties, it creates different properties by adding numeric suffix.
For example, ...
0
votes
0
answers
128
views
NLog in ASP.NET Core: how to inject a logger with a specific property
I'm developing an ASP.NET Core (.NET 8) web application where I'm using NLog as my logging library.
I have a service in my application where I want the logger to output to a specific file instead of ...
-1
votes
2
answers
133
views
C# NLog: Why doesn't it produce output?
in my C# application (.NET Framework 4.8.1) i want to do some logging and messaging. For this purpose I decided to use NLOG and I don't want to configure this using the config file but ...
0
votes
1
answer
60
views
Configuring different Loggers in NLog to output in different log-levels, but to the same target
I'm using NLog.Extensions.Logging v5.3.15 (NLog v5.3.4) in my .Net 8 Console Application.
I want, that loggers called Microsoft.* write with minimum Log-level Info and all the rest of loggers with ...
1
vote
0
answers
95
views
NLog IgnoreFinal and LogFinal - are ALL subsequent rules ignored ? or only those matching the current filter rule?
The NLogs docs (https://github.com/NLog/NLog/wiki/When-filter#parameters) say:
IgnoreFinal - The message should not be logged and ignore any following logging-rules.
LogFinal - The message should be ...
1
vote
0
answers
52
views
Dynamically Get Project Solution Name in Nlog.Config file
We have a Blazor Template that we created for our team, to help new developers get up and running faster. One of the pre-installed NuGet packages that we are including with this template is Nlog.
I ...
0
votes
1
answer
125
views
NLog 5.3.4 not writing logs to SQL Server table
Using an ASP.NET Core 8 Web API, I tried to implement logging to a SQL Server table.
SQL Server version used:
Microsoft SQL Server 2019 (RTM-GDR) (KB5046859) - 15.0.2130.3 (X64)
Oct 18 2024 15:25:23 ...
1
vote
1
answer
561
views
Suppress Logger output from EF Core SQL when using NLog
I am trying to get EF Core to stop writing SQL to my log files. I am using NLog. I have the following in my appsettings.json:
"Logging":
{
"LogLevel":
{
"...
2
votes
1
answer
256
views
NLog.Web.AspNetCore 5.3.12 raises System.UriFormatException with <TargetFramework> net9.0
FYI to NLog devos:
I have a VS 2022 ASP.NET Core solution that works under .NET 8.0. I updated the TargetFramework to net9.0 and everything works normally. Then I updated all of the NLog.* packages to ...
0
votes
0
answers
57
views
How to use a fallback when it cannot send data to CloudWatch (C#,AWS.Logger.NLog)
In cases where sending to CloudWatch fails under any circumstances, write to a log file instead.
Remark : I tried inputting an incorrect config value, but it did not go into the catch block.
I Used ...
0
votes
2
answers
91
views
Redirect NLog logging output to file specified by the logger
I want all messages to go to all.log file and if logSource property is set then message should also go to logSource file. If I uncomment the when filter then the logSource file is not created. I added ...
1
vote
3
answers
156
views
NLog override level use JSON configuration
I have Asp.NET Core application that uses a third-party library that outputs messages with the INFO information level:
_logger.LogInformation("About information...");
This is about how the ...
2
votes
1
answer
2k
views
Disable default logs for ASP.NET Core application
I'm trying to disable the default logging from an ASP.NET Core application. I'm using NLog with a nlog.config file and I have tried adding the Logging section to the appsettings.json file, but still I'...
-1
votes
1
answer
124
views
How can I correctly measure the time, needed for operations and instructions, in a multi-threaded C# application, using NLog?
I have a background in UNIX server programming, where speed analysis is extremely simple: just add logs and verify the differences between subsequent entries.
This way of working, however, seems to be ...
1
vote
0
answers
48
views
IPBan nlog.config 'archiveEvery' parameter
I have been using IPBan for a few days,
and now there are many log files,
with each file only containing a few lines of log.
I'd want to configure the nlog.config file to change the archive period.
I'...
0
votes
1
answer
132
views
DateTime NLog c#
I am trying to write to my database the date of now with NLog and I have this error:
SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
I tried everything but ...
-1
votes
1
answer
89
views
Can i "outsource" the NLog-portion of appsettings.json?
I have a bunch of different appsettings.json for a number of customers. However, the nLog-portion of these appsettings never changes, so I'd love to have one single json-File for the nLog-config.
So I ...
1
vote
0
answers
171
views
Add structured logging parameters with object instance values
Assume following object model:
public class FooManager {
private ILogger _logger;
private Dictionary<string, Foo> _instances = ...
// CRUD interface
}
public class Foo {
public ...
0
votes
0
answers
351
views
UseSerilog vs AddSerilog: any functional difference in an asp.net application?
I have created a project to test serilog, nlog and log4net at the same time being unaware that depending on what you do this might not work and discovered in fact that calling UseSerilog would not ...
0
votes
1
answer
47
views
Web.config transform on custom section with attributes
I would like to transform a part of my 'web.config' file using a transformation file, but the value I am trying to change is within sections with attributes and the transformation does not occur if I ...
0
votes
0
answers
71
views
WixToolset v4 util:XmlFile NLog.config Element XPath ElementPath and its Value
I would like to edit the NLogConfig file with MSI Installation using WiX Toolset v4.
Using the util:XmlFile from WiX Toolset. I get an error message at compliation:
"ICE03: Invalid format string; ...
1
vote
2
answers
183
views
C# NLog add rule doesn't seem to work for some reason
I am trying to block some not needed Microsoft debug logs in my app. I have a separate settings file where nLogLevel is set as either info or debug depending what my settings say. When nLogLevel is ...
0
votes
1
answer
61
views
nlog INSIDE of a Soap Api
I want to log information INSIDE of a soap api, using NLOG. But all I am finding is how to setup NLOG so the external website makes a call to the api and it uses NLOG to log the data. I need to see ...
-1
votes
1
answer
67
views
why there's no output file
i try to find the answer but they are almost 6 years ago or older.then i see the issue on github. i try to custom a target following github but failed
i get the dll file from nuget package and add to ...