Questions tagged [nlog]
NLog is a free logging platform for .NET
2,588
questions
1
vote
1
answer
24
views
Elastic Search : {"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index using NLog in asp.net core
This error comes when I searched the index in elastic search by http://localhost:9200/myservicename
following is my n.config file
<target xsi:type="BufferingWrapper" name="...
0
votes
1
answer
23
views
Nlog structured logging not working for classes
I have following code:
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
logger.Info("Application starting");
var a = new A() { B = 5, C = "...
0
votes
0
answers
10
views
NLog Console Window Not Opening
I've been using NLog for about 8 months and I absolutely love it! I maintain a dozen or so REST APIs that I manage with Visual Studio. Whenever I run the application from VS, Swagger opens up in my ...
0
votes
0
answers
27
views
Why is NLog multi process logging so fast?
I try to write log util myself. If I use mutex, it will be much slower than NLog anyway. If I don't use mutex, there will be a probability of losing logs anyway.
NLog code:
fileStream.CopyAndSkipBom(...
0
votes
1
answer
27
views
Nlog prevents update database in Aspnet Core
I'm using NLog in my ASPNETCore Web Api project,
I have and issue in Update-Database while using NLog
This is my NLog.Config file in my application :
<?xml version="1.0" encoding="...
0
votes
0
answers
21
views
How can you make two different NLog targets with same date inside?
I have the following two targets defined in NLog.config inside my ASP.NET Core project:
<targets>
<target name="MyApp" xsi:type="File"
fileName="${...
1
vote
0
answers
40
views
Add-Type fails to compile C# source with references to NLog types
I am trying to add a type in PowerShell v5 using C# source that references the NLog v5.0.0 logging library.
When I execute the following MRE:
$source = @'
namespace Test
{
using System;
...
1
vote
0
answers
19
views
Is there a way to set variable value only once in NLog
I am trying to set NLog in ASP.NET Core project in a way that it would read the date ONCE and then create a file target based on that date. This is what I have:
<variable name ="CurrentDate&...
0
votes
1
answer
24
views
Unable to reduce verbosity of specific loggers in NLog
I upgraded from NLog 4. to NLog v5 a couple of days ago in an ASP.Net / .Net 6 environment. As soon as I updated I noticed that I was getting details from many more loggers than I had in the past (I ...
0
votes
0
answers
18
views
NLog Config - How to use a layout variable inside a CompoundLayout?
In my NLog Config I have a variable to hold my JsonLayout:
<variable name="jsonLayoutv0.1">
<layout type="JsonLayout">
<attribute name="time" ...
1
vote
1
answer
42
views
How log to event properties without placing them in the message?
I'm current using NLog to log into Json format. I want to log event args in my logs under "eventProperties" without them being included in the message attribute.
Current nlog.config:
<...
1
vote
1
answer
42
views
How to reload Logger when appsetting.json has reloaded?
I'm trying to control LogLevel in log from appsetting.json. I've added my Nlog config here and custom field LogLevel. In rules I've added "${configsetting:item=LogLevel}" and it works. But I ...
0
votes
1
answer
40
views
Convert NLog.ILogger to Microsoft.Extensions.Logging
I am using NLog as logging provider in my solution, but some projects have migrated to Microsoft.Extensions.Logging. We're still evaluating if migrating also the rest of the code to this, but in the ...
1
vote
1
answer
59
views
layout="${aspnet-request-posted-body}" in the NLog.config now causes an internal NLog exception
NLog, NLog.Database, NLog.Extensions.Logging, and NLog.Web.AspNetCore are on version 5.0.0.
The platform is .NET Core 3.1.
This used to work fine in the NLog 4.x series, but now this causes an ...
1
vote
0
answers
47
views
Nlog logger object gets disposed when it shouldn't
We're using NLog for our application. I have set up the logger in the code using mostly the documentation. Yet the logger object gets disposed of while the app is about to write to it causing an error....
0
votes
0
answers
11
views
NLog.Web view component name
I have a page where we have multiple view components. I made a change on some components at the same time and in the log I was getting a warning. However in the log I can not see the viewcomponent ...
0
votes
0
answers
30
views
NLog: reference properties in message
I am using NLog with structured logging for the first time. I user Serilog in the past, and with that I could write something like this:
Serilog.ILogger logger = CreateSerilogLogger();
logger....
0
votes
0
answers
22
views
Cannot authenticate using API Key with NLog.Targets.ElasticSearch
I cannot get NLog.Targets.ElasticSearch to connect to a local ElasticSearch instance using an APIKey.
My nlog.config has the following:
<target xsi:type="BufferingWrapper" name="...
1
vote
0
answers
21
views
Nlog.config not writing the logs after sometime
I am having an issue with Nlog not writing logs to the folder mentioned in the config file. This is for windows service we implemented. Whenever we start a service, it writes the logs for few days/...
0
votes
0
answers
18
views
Nlog: Changing file name by day
I'd like to have a simple log file scheme with NLog: Create the current log file, after the current date, change it's name to current date .log.
So something like:
log.log <-- Today's date
2020-11-...
0
votes
0
answers
54
views
Logging URL in Blazor Server using Nlog
I'm currently using NLog with Blazor Server and storing generated logs in a database. One of the data points I would like to store is the URL that the user was on when the log was created.
In other ...
-1
votes
0
answers
67
views
NLog in .Net 6 Winforms app - not logging unless on demand
We are trying to implement NLog in a Winforms application that has been migrated to .Net6. We can have it create a log file and log entry by firing a .LogInformation event in the application, but we ...
1
vote
1
answer
86
views
Could not load file or assembly 'NLog.Web.AspNetCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c'
I'm upgrading my solution from .NET 5 to .NET 6 and getting the error at runtime
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'NLog.Web.AspNetCore, Version=4....
1
vote
1
answer
47
views
How to increase NLog log level at runtime
My application has too much log.Trace() at the beginning of the program, causing the program to malfunction, so I can't use general NLog configuration to increase the log level.
So, I would like to ...
0
votes
1
answer
73
views
Struggling to add custom NLog layout renderer in .Net 6 Web API
I have a .Net 6 Web API. I use NLog for my logging. I'm trying to log a custom field with NLog, but I am struggling to get it to work. I'm following this sample: https://nlog-project.org/2015/06/30/...
1
vote
2
answers
81
views
NLog: how to specify log folder at runtime
For an example, i have following code (ASP.NET core 6):
Program.cs:
//...
var config = new NLog.Config.LoggingConfiguration();
var logfile = new NLog.Targets.FileTarget("logfile")
{
...
0
votes
1
answer
33
views
what's the relationship between `system.diagnostics.trace` and nlog/log4net?
I am learning asp.net web API (framework, not core). generally, I will use system.diagnostics.trace to write logs. but a bro suggests to use Nlog.
is Nlog/log4net a wrapper of system.diagnostics.trace?...
0
votes
0
answers
18
views
NLog logging to oracle database issue
Can we use "Oracle.ManagedDataAccess.Core" data provider instead of Oracle.ManagedDataAccess to log errors in Oracle database ?
I am trying to log error from .NET core web API to Oracle DB.
...
0
votes
1
answer
36
views
How to set NLog's internal LogFile programmatically for dependency injection
I know you can set NLog's internal log file programmatically like this:
NLog.Common.InternalLogger.LogFile = @"C:\Logs\nlog.log";
The above trick does not work for the following scenario, ...
0
votes
1
answer
68
views
NLog ApplicationInsights - Instrumentation Key from appsettings.json only loading for TelemetryClient
In my .NET 5 aspnetcore application, NLog is mostly working except for loading the Instrumentation Key from appsettings.json for the logger. It seems to be loading for the TelemetryClient just fine.
...
0
votes
0
answers
28
views
NLog date won't run in Linux Mono. (System.NotSupportedException)
I'm new on using NLog and C#. The configuration works correctly under Windows system. However, when I tried running it under VPS server. It shows this error message saying that the Date layout isn't ...
0
votes
0
answers
50
views
Logging error to Oracle database from ASP.Net core 3.1
I want to log exceptions from .Net Core Web API to Oracle database.
I started using NLog but nothing is getting logged into the database. Also, there is error in the internalLogFile.
The below ...
1
vote
1
answer
66
views
Azure Blob Trigger Function triggering only once when file is updated with NLog
I am using NLog to log the messages in azure blob storage with blob name as dd-mm-yyyy.log. For each and every message which I inserted into "dd-mm-yyyy.log" file, I want to call/trigger the ...
0
votes
1
answer
26
views
Logging disabled when using NLog-Logger in PowerShell
My nlog.config
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xsi:schemaLocation="NLog NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"...
0
votes
0
answers
28
views
NLog code breaks when updating from .net 2.2 to 3.1
we are in the process of upgrading some projects to .NET 3.1
I get the following error after changing to 3.1:
'IWebHostEnvironment' does not contain a definition for 'ConfigureNLog' and the best ...
0
votes
1
answer
49
views
NuGet package is not completely installed
I am creating a NuGet package via Azure DevOps. The NuGet package contains an Example.exe file and an Example.exe.nlog file. So far all is well. WWhen I install the NuGet into my project in Visual ...
0
votes
0
answers
22
views
How to set the logGroup programatically for CloudWatch using Nlog and MDLC
I'm using AWS.Logger.NLog to send logs to CloudWatch.
What I'm trying to do is to assign the logGroup programatically, instead of putting it in the nlog.config. I tested other config parameters like ...
0
votes
0
answers
35
views
How to find out NLog files on Azure App service: Azure devops dashboard
I have configured NLog like so and all are working fine on development mode. I can see those files under this path: \bin\Debug\net6.0\logs.
I have published the app to the Azure App service. So can ...
0
votes
1
answer
24
views
nlog moving log halfway through program execution
I have a program that does the following things
Start program execution, log timestamp
Read command line inputs and parses arguments
Based on arguments, creates a new log in the desired directory
...
0
votes
1
answer
38
views
Nlog Delete SQLite longer than X days
xsi:type="File" has maxArchiveFiles="5" archiveEvery="Day" properties. Is that possibble to delete db content older than X days?
xsi:type="Database" has rules ...
0
votes
1
answer
427
views
.NET Core 6, NLog And ILogger, log to SQL Server database, custom fields issue
I use .NET Core 6 with NLog used via ILogger, to access information in a SQL Server database.
I have two custom fields that I cannot save in the database. For these two fields I always got 0 in the ...
0
votes
0
answers
24
views
How to add a computer environment variable to a console application as a path pointer for logging
I created a variable on the computer and specified the path to the folder through it, then specified it in the NLog.config file
fileName="${environment:LOG_DIRECTORY}${date:format=yyyy-MM-dd}...
0
votes
1
answer
78
views
Application insight not receiving Nlog for hosted service
I try everything I can think of but I must miss something.
I have a hostedService project in netcoreapp3.1
I referenced the following
<PackageReference Include="Microsoft.ApplicationInsights....
0
votes
1
answer
90
views
Configure in the appsetting Nlog to write in Seq
I have an application in net core, the application writes all the logs in SeqLog, I used Nlog to configure everything and so far I have used an .xml file to give Nlog all the information useful for ...
1
vote
0
answers
35
views
C# : Why won't NLog generate a log file even with no errors
Here's my Nlog.config
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/...
2
votes
1
answer
328
views
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 ...
0
votes
1
answer
114
views
No log data in Elasticsearch with NLog.Targets.ElasticSearch
I'm trying to log to Elasticsearch with NLog using NLog.Targets.ElasticSearch.
The index is created successfully but no log data found.
my NLog config:
<?xml version="1.0" encoding="...
0
votes
0
answers
37
views
Nlog : With mail target - SecurityProtocol
I have issue Nlog with mail target.
Appllication build in framwork 4.5.2.
Nlog : 4.7.14
Now Nlog configration is as below,
<target name="mail" xsi:type="Mail" html="true&...
0
votes
0
answers
36
views
What is the correct way to load the Nlog configuration from web.config at website startup in .NET Framework 4.6.1?
I’m converting a web application/web site from log4net to NLog. The code has this line:
Log4net.Config.XmlConfiguration.Configure();
This loads the logging configuration from the Web.Config file ...
-1
votes
1
answer
85
views
How to configure NLog in app.config in .net 6 to write on 2 different targets?
I want to configure NLog to write in a file and also to send the logs via http sink to an application i build which saves the logs also in database.
How is done the configuration of NLog in app....