Questions tagged [microsoft-extensions-logging]

53 questions
4
votes
3 answers

ASP.NET 5: How to configure the path of logs in Microsoft.Extensions.Logging

I'm working on an MVC6 web app and I'm new to ASP.NET 5. I can see that the Logging (Microsoft.Extensions.Logging) is used at many places (eg: AccountController.cs) in ASP.NET 5 default web application template, but I couldn't figure out where to…
3
votes
1 answer

Set Log Levels for Microsoft.* , System, and AspNet when using Serilog

I had always imagined that "Logging": { "LogLevel": { "Default": "Debug", "System": "Information", "Microsoft": "Information" } }, would set my project code's log level to Debug, and make Microsoft.* namespaces log at…
3
votes
0 answers

Register NLog as the Microsoft.Extensions.Logging provider for other components

I am writing a .Net Core Console app. I am using NLog, by itself, extensively in my application. (Calling NLog.LogManager.GetCurrentClassLogger() and calling log methods on that.) I am making use of Entity Framework, which provides a way to control…
David Yaw
  • 27,383
  • 4
  • 60
  • 93
3
votes
1 answer

Microsoft Extension Framework add custom dimensions to the logger instead of each call?

I have an azure function: public void Run([TimerTrigger("0 0 0 * * *", RunOnStartup =true)]TimerInfo myTimer, ILogger log) { using (logger.BeginScope(properties)) { logger.LogTrace(message); } } Dictionary
3
votes
1 answer

How can you prevent NLog from handling log statements in referenced libraries?

Whenever an error occurs within our API, we end up getting multiple emails for a single error. Based on the log messages; we can see that these other emails seem to be getting generated because various Microsoft libraries are calling something like…
2
votes
1 answer

How does MS default ILogger (Microsoft.Extensions.Logging.Logger) interpret args?

It is a bit confusing to me how args is interpreted by the lib. According to the official site (https://learn.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-6.0&viewFallbackFrom=aspnetcore-2.2#log-message-template), It is "The…
kzfid
  • 688
  • 3
  • 10
  • 17
2
votes
2 answers

C# streamlined way to get Exception line number into Serilog

I am using this code using serilog to get write the line number of the exception into my logs. The problem here is the line number is where the exception is thrown in the catch block and not the actual line where the exception occurred. The…
CodeMan03
  • 570
  • 3
  • 18
  • 43
2
votes
1 answer

Extending the ILogger interface

I'd like to add a method to the ILogger interface. For logger types not implementing this function I'd like them do do nothing (or use a default implementation). For those that do, their implementation should be called. This below doesn't work.…
Adam V. Steele
  • 559
  • 4
  • 18
2
votes
1 answer

Setting CustomDimensions with the Microsoft Extension Logging framework

I have set up application insights for asp.net core project. appsettings.json: "ApplicationInsights": { "InstrumentationKey": "90f786b7-36a5-xxxx-b1fc-xxxxxxxxx" }, Startup.cs: services.AddApplicationInsightsTelemetry(); And in my…
2
votes
1 answer

System BadImageFormatException Format of the executable (.exe) or library (.dll) is invalid

CI pipeline taking about 50 min to complete and most of the time is consumed by the test. Have good number of unit test and data driven tests. Have decided to run test in parallel and the approach took based on this doc Run Tests In Parallel In…
2
votes
1 answer

NLog EventProperties in .NET Core

I'm using ILogger to write logs using DI (see step 6) I'm also using NLog EventProperties I want to add traceId to all my logs in my controller automatically. This is working: logger.Info("Some log. TraceId:{traceId}", 123); However,…
2
votes
1 answer

How to configure MS.Extensions.Logging log levels in an Azure Function?

I have an Azure Function that exhibits some unexpected logging behavior. The host.json file is this: { "version": "2.0", "logging": { "fileLoggingMode": "never", "logLevel": { "default": "Information", "Function":…
E-Riz
  • 31,431
  • 9
  • 97
  • 134
1
vote
1 answer

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 on the main application form. (Package versions:…
1
vote
0 answers

What makes a log event id unique in ASP.NET Core?

When logging w/ event id's like this: logger.LogInformation(1001, "Getting item {Id}", id); How do I query a semantic or structured log, for those events? What are the key(s)? I'm guessing EventId.Id + SourceContext? (There's no guarantee the id…
1
vote
0 answers

An unhandled exception of type 'System.ArgumentNullException' occurred in Microsoft.Extensions.Logging.Abstractions.dll: 'Value cannot be null.'

This is my Program.cs class private static void ConfigureServices(ServiceCollection services) { var serilogLogger = new LoggerConfiguration() .WriteTo.File("TheCodeBuzz.txt") .CreateLogger(); …