Questions tagged [microsoft-extensions-logging]

53 questions
1
vote
1 answer

Creating custom extension functions for logging with NLog

I am using NLog in a .Net Core 2.2 project. I want to implement a category system for my logs using EventId (supported in NLog). Currently I am using the logger like this: logger.LogInformation(new EventId(5, "UserLogin"), "The user: {username}…
1
vote
1 answer

How to automatically delete logs in ASP.NET 5?

I have a web application using ASP.NET 5. I'm just getting familiarized with the new built-in logging mechanisms (Microsoft.Extensions.Logging). I was using NLog in other applications prior to this, and NLog has an mechanism to automatically delete…
painiyff
  • 2,519
  • 6
  • 21
  • 29
0
votes
1 answer

In Blazor how do I get Logger talking to ApplicationInsights

I am finding explinations like this (and others) reference methods that don't exist. There is no builder.Logging.AddApplicationInsightsTelemetry() nor is there a builder.Services.AddBlazorApplicationInsights() What I did try was: var builder =…
0
votes
1 answer

Can I use ILogger.BeginScope() in Blazor (server)?

I have the following code for a page in my code: string username = user.Name; using (Logger.BeginScope("User:{username}", username)) { if (Logger.IsEnabled(LogLevel.Trace)) Logger.LogTrace($"/Manager/Campaign ModeState={ModeState}…
0
votes
0 answers

Why are dll files not being created when I build my console app

I have been working on a logging project (class library), where we use Microsoft extensions logging logger instance and serilog as a logging provider to write the logs to json file. I have completed the project, now I'm testing it in my local…
0
votes
0 answers

Microsoft Extensions Logging with ASP.NET MVC 4 Web app and dependency injection

We have an ASP.NET MVC 4 web app and I am trying to add Microsoft Extension logging using dependency injection methodology but unable to do. Here is my BaseController where I am trying to initiate ILoggerFactory property which I wish to use across…
Ris
  • 1,152
  • 7
  • 29
  • 63
0
votes
1 answer

Using a custom value text formatter with Microsoft ILogger

I've currently got some code that looks like this: _logger.LogInformation("Found a problem {Problem}", Format(problemDetails)); where Format converts ProblemDetails to a string. I would like to register a handler within the logging framework to…
Julian Birch
  • 2,605
  • 1
  • 21
  • 36
0
votes
0 answers

how can I write back to source excel file when I get excel data from data tab?

So, I want to create one Excel file each for every manager with only one single sheet and place it on OneDrive. In order to get the data in one place, I am creating another excel file called combined.xlsx. Now, I can export each workbook to a tab…
0
votes
0 answers

How to mock Eventlog with WebApplicationFactory

I have a application with a Log4net RollingFileAppender for info-logs and a EventLog for error-logs builder.ClearProviders() .AddEventLog(new EventLogSettings { SourceName = "ABC"}) .AddLog4Net(); Configured in…
0
votes
0 answers

How to selectivley log using Microsoft Extension Logging?

I am trying to fully implement Microsoft Extension Logging (MEL) in a new .Net Core Web API service. Not have any issues adding/configuring providers but trying see how implement some more granularity in the logging. The following example creates a…
0
votes
1 answer

Add logging context to all Azure Function logs

By default, Azure Functions adds logging context data to all logs. Is it possible to add other context items to be logged globally? Specifically, I'd like to add global data such as the build number. I can't find any sort of hooks that don't require…
0
votes
5 answers

Why do I get this error in the static class ? -> Readonly field _logger is never assigned

I am using ILogger in my static class. The codes in the class shown in below: internal static class LicenceSetter { private static ILogger _logger; internal static void WorkWithStream(Action setLicence, string name = null) { …
Masoud
  • 65
  • 9
0
votes
0 answers

How to configure Logging without appsetting.json?

I am working on .net framework 4.7.2 web API which doesn't have appsetting.json. I wonder where should I configure the below setting for Microsoft.Extension.Logging? "Logging": { "LogLevel": { "Default": "Information", …
0
votes
1 answer

Logging errors to AppTraces instead of AppExceptions?

I have an azure function app that uses the microsoft extension logging to application insigths. I have this code: public static void Run(IService service, ILogger log, bool throwException, bool addHeartBeat = false) { try { if…
0
votes
2 answers

MissingMethodException Serilog.Context.LogContext.Push

I did some consolidation of my NuGet packages across my solution and now I'm receiving: exception message: MissingMethodException: Method not found: 'System.IDisposable Serilog.Context.LogContext.Push(Serilog.Core.ILogEventEnricher)'. call stack…
spottedmahn
  • 14,823
  • 13
  • 108
  • 178