Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
17 views

Log not updating in file for other project in solution using Ilogger factory and Nreco in Blazor

I have some projects in a solution where the main project is Blazor Server. I have installed Nreco logger in the Blazor Project to post various logs. Program.cs using BlazorApp; using BlazorApp....
KhataPlus's user avatar
0 votes
0 answers
25 views

UseSerilog is being executed twice on Application Startup

I'm using Microsoft.Extensions.Hosting and I am using UseSerilog to bring Serilog as the only logger. var hostBuilder = Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args); hostBuilder....
MrHinsh - Martin Hinshelwood's user avatar
0 votes
0 answers
47 views

ASP.NET 8.0 Core App 2024 getting error: Exception System.PlatformNotSupportedException: EventLog access is not supported on this platform

Update. So when running the application from the Debug directory unser the project in Visual Studio. it works. In the same exact command prompt and changing to the installation directory, I get the ...
acodingguy's user avatar
0 votes
0 answers
12 views

Create ILogger<T> using c# class name for xUnit Service class initialization

I have a large project with hundreds of c# class files. Need to write xUnit tests for services' functions which depend on many arguments and there may be dependencies of these classes on one another. ...
user3104116's user avatar
1 vote
2 answers
127 views

Adding extra properties to ILogger<T> structured logging

Using ILogger<T>, is there a way to add log properties in addition to the ones covered by the message template? For example: _logger.LogInformation("Order {OrderNumber} was registered."...
Sigurd Garshol's user avatar
1 vote
1 answer
125 views

Can't see logs in Azure Log Stream .NET 8

I want to set up logging for my azure deployed ASP.NET Core web app. I can see the logs just fine when running the app locally, but when deployed to Azure the Log Stream doesn't show anything. In ...
Eric's user avatar
  • 11
1 vote
0 answers
36 views

What is the best/suggested way in C# to get an instance of ILogger<TCategoryName> for those classes which are not registered by the DI framework

Let say I have a class called Person and defined like below public class Person { public Person(string name, int age); ... } This is not a service class registered (by calling AddSingleton, ...
kzfid's user avatar
  • 768
0 votes
0 answers
50 views

FormatException with ILogger after project upgradation from .NET 6.0 to 8.0

I am upgrading a existing running project from .NET 6.0 to 8.0 and ILogger and Serilog are in use and it is running perfectly(no logging error/warning) with .NET 6.0. Here is the sample code //...
Praveen Kumar's user avatar
0 votes
0 answers
94 views

How to reference ILogger in C# winforms application

Below is the code I have added to the Program.cs file in my code. What I want to be able to do is write a log message from any one of the forms in my application. Would prefer to write it to a .log ...
SQL Pup's user avatar
  • 21
0 votes
1 answer
91 views

options.TimestampFormat is deprecated. What is the alternative?

I've created a ILoggerFactory, and added a console provider. I want to add timestamp, but it sounds like options.TimestampFormat is obsolete. private static ILoggerFactory _loggerFactory = ...
ninjarubberband's user avatar
2 votes
0 answers
69 views

How to use ILogger.BeginScope in Blazor Server for the entire activity?

In a standard request/response app with AspNet.Core, it was easy to add informations to the request context so that every single log entry could have access to them automatically. For exemple, if I ...
Alexandre Jobin's user avatar
0 votes
0 answers
67 views

,NET 8 Custom ILogger questions

I am trying to create a custom ILogger, but I am having difficulties with some of the concepts. Here is the sample code I have: using Microsoft.Extensions.Logging; public sealed class AzTableLogger(...
Herald Gjura's user avatar
1 vote
1 answer
25 views

Xunit verify is not working in a mocked logger

I have the following code, namespace MarketData.Service.Diagnostics { using System; using System.Collections.Generic; using System.Data; using Microsoft.Extensions.Logging; public ...
Garry A's user avatar
  • 455
4 votes
1 answer
218 views

add logs to traces with ILogger (.Net web api)

I want to add some logs to my traces using, ILogger, opentrlemetry protocol and Jaegercollector. this is my code: var serviceName = "some_service_name" + mode.ToString(); var ...
Mohamad Lashgarbolok's user avatar
0 votes
1 answer
160 views

Event log source is not created after publishing a .NET Core 8 web site

I am using Logger to log errors in my web application. It works perfectly in my development machine but not when published. This error is logged in the event log (using Application source): Unable to ...
jstuardo's user avatar
  • 4,451
0 votes
0 answers
52 views

I am not able to display all my log information or error messages(if any) on browser in my ASP.NET Web with Worker service project using Serilog

Project description: I am using .NET Core7 which I used to built an web application with background service using asp.net web api template and worker service template. I am using Serilog provider to ...
nilyad65's user avatar
0 votes
1 answer
91 views

Unable to Add File to either ILoggerFactory or SeriLog

I have an API application and I want to write the logs to a file. I am getting errors trying to add file to iLoggingBuilder and to Serilog. The compiler says that the methods, that I have seen used ...
NomadicDeveloper's user avatar
1 vote
1 answer
132 views

NLog is not writing when using nlogsettings.json file

I am trying to write logs using ILogger from Microsoft.Extensions.Logging and with NLog as a provider. I added a separate nlogsettings.json file to define configuration because to maintain appsettings ...
alienavatar's user avatar
1 vote
0 answers
61 views

In C#, How can an interface (such as ILogger), with 1 method signature for log(), show 5 on intellisense?

As per the title, how is this done? I understand that the framework has its own class with overloaded extension methods for objects of type ILogger<t>, but what I don't understand is how these ...
Bobby Bridgeman's user avatar
0 votes
0 answers
54 views

serilog sinks mssqlserver doesn't write completely response body on database

I'm using Serilog.Sinks.MSSqlServer package version 5.8.0 I'm using this configuration for create my custom columns var dbColumnOptions = new ColumnOptions { AdditionalDataColumns = new Collection&...
Ezequiel Merecías's user avatar
0 votes
0 answers
162 views

Creating a custom serializer for complex object in a single line in the output logs

I have a object which is used in multiple places. I created a logger for logging in pino. Is there a way to log the following object which I get from making a restful call to a service, ...
BreenDeen's user avatar
  • 642
0 votes
0 answers
211 views

Is there a way to get all logging providers, and for each their LogLevel settings?

For the ASP.NET ILogger system, is there a way to get all providers that are running in my app? And then for each provider get the LogLevels set for that provider? I want to log the logging as it's ...
David Thielen's user avatar
0 votes
1 answer
194 views

Why am I not getting Trace logging on Azure App Server

I am using the same log settings on my dev system and on Azure. Both use appsettings.json. I have no Logger settings in appsettings.Development.json or secrets.json on my dev system. I have none in ...
David Thielen's user avatar
0 votes
1 answer
62 views

Calling log on custom middleware

I have a following custom middleware for error handling public static class ErrorHandlerExtensions { public static void UseErrorHandler(this IApplicationBuilder app) { app....
angie's user avatar
  • 3
0 votes
0 answers
86 views

How to log Failed DbCommand as warning instead of error

I have a known problem within a query which I would like to log only as a warning. My issue is that every time the error occurs, I get a log entry for "Failed executing DbCommand" as an ...
TheProgrammer's user avatar
1 vote
1 answer
427 views

Linux Azure App Service - Unable to populate AppServiceAppLogs in Log Analytics

I am struggling to populate the Log Analytics AppServiceAppLogs sink with application logging. I have a .NET Core Web Api hosted in a Linux hosted App Service Plan and using the default MS ILogger ...
Cam Bruce's user avatar
  • 5,679
1 vote
1 answer
97 views

Microsoft.Extensions.Logging, ILogger, get a count of errors?

When using Microsoft.Extensions.Logging in a .NET application, is there a way to get the current count of errors that have been written to the log? I figure I can probably implement a custom ILogger ...
Sigurd Garshol's user avatar
0 votes
1 answer
73 views

Where can I find the function that formats a log string and its parameters with the new Structured Logging format?

Where can I find the function that formats a log string and its parameters with the new Structured Logging format. I'm looking for the equivalent of "string.Format(..." but for Structured ...
Eric Ouellet's user avatar
  • 11.6k
0 votes
2 answers
449 views

How to access ILogger in all classes in Azure Function running on .NET Core 6 isolated

I'm converting a web job to an Azure Function. I created an Azure Function with .NET 6 isolated. I'm unable to access the ILogger from class constructor, getting this error: System....
prasanthi's user avatar
  • 606
0 votes
1 answer
183 views

NLog Writing log within ConfigureServices cause log to lose ${aspnet-request-url} & ${aspnet-mvc-action} throughout the app

I use NLog for writing logs on my Web API apps, (.Net 6) And I needed to write to the log inside the ConfigureServices method. Since ILogger is not available at this point, I used this way to write to ...
banana's user avatar
  • 1,206
2 votes
1 answer
312 views

Configure log level in .NET 7 and Serilog

Trying to figure out how to use Serilog under Microsoft Ilogger abstractions. The latter reads log level settings under the "Logger" section in appsetting.json, while Serilog reads log level ...
Kjell Rilbe's user avatar
  • 1,463
0 votes
1 answer
273 views

Serilog Not Logging to File

I am attempting to log both errors and information on API requests in my .NET Core 6 project. After setting it up in my Program.cs file it does output a log entry to the desired location. Below is my ...
Deus Ex Machina's user avatar
1 vote
1 answer
701 views

Using both ILogger and Application Insights Telemetry in .Net Framework

There are a few similar questions but none have really answered my question. I'm wanting to use Ilogger to log my custom user logs but still keep the Visual Studio "auto" added Application ...
punkologist's user avatar
0 votes
0 answers
251 views

Is there a way to configure ILogger to use single line unless message itself is multiline?

When my configuring ILogger looks like this: services.AddLogging(options => { options.AddSimpleConsole(c => { c....
greenoldman's user avatar
  • 20.8k
0 votes
1 answer
119 views

How to capture Ilogger.LogInformaiton in Azure portal for AppService Logfile implemented in ASP.NET Core 6

With the help of forum and research I am able to view the logfile for the errors occur in hosted ASP.NET Core 6 Web API. So when the error occurred, I captured that under _logger.LogError("error)....
Faisal's user avatar
  • 119
0 votes
2 answers
247 views

Stop logging from TableClient

I have a function app that uses a table client. svc.AddAzureClients(bldr => { var serviceUrl = tableStorageSection["ServiceUrl"] ?? throw new ArgumentNullException("Missing value ...
Stif's user avatar
  • 935
1 vote
1 answer
305 views

Application Insights does not collect ILogger error logs

I am using App Insights. It is configured for my app service and it tracks failures, but unfortunately I can't see my ILogger.LogError logs. LoggingLevel is set to Warning. builder.Services....
lolo xoxo's user avatar
0 votes
1 answer
165 views

ILoggerProvider - one gets config, the other does not (or gets the other)

This is really strange. I have a simple example here. Please note in the sample (linked above) I have: public BlobLoggerProvider(BlobLoggerOptions options) { Options = options; Options = new ...
David Thielen's user avatar
3 votes
1 answer
527 views

Manually render log template used in .NET logging

In .NET one logs like so: logger.LogInformation("Hello {What}", "World"); Which renders: Hello World I need to manually render that template (the upstream code is not mine and I ...
lonix's user avatar
  • 18.5k
2 votes
2 answers
482 views

Trying to get appSettings.json settings in an ILogger provider

The ILogger provider I created runs fine. But I have two problems: The appSettings.json are not passed in to the provider constructor. The logging system ignores the appSettings.json set specifically ...
David Thielen's user avatar
0 votes
1 answer
292 views

Is there an ILogger provider to write to a local file, or to Azure BLOB?

Is there a sample or library for writing a provider for the ASP.NET Core ILogger system that writes to a local file and/or to Azure BLOB storage? Please do not suggest Serilog as it does not work (for ...
David Thielen's user avatar
4 votes
1 answer
286 views

Why is ASP.NET ILogger ignoring my log levels?

I am using the ASP.NET ILogger system in a Blazor server app. I instantiate it as follows: using (var loggerFactory = LoggerFactory.Create(loggingBuilder => loggingBuilder ....
David Thielen's user avatar
1 vote
1 answer
443 views

ApplicationInsights logging with ILogger is duplicating traces - logs appearing twice

I have a .NET Core API and I am logging to Azure AppInsights using ILogger DI. This is using the Microsoft.ApplicationInsights.AspNetCore nuget package and documentation here: https://learn.microsoft....
James McCormack's user avatar
0 votes
1 answer
94 views

What do I miss with ILogger<T> via Dependency Injection?

I have the following sample code: [assembly: FunctionsStartup(typeof(Playground.Startup))] namespace Playground { public class Startup : FunctionsStartup { public override void ...
Mark Zoeltsch's user avatar
0 votes
1 answer
190 views

Ilogger not emitting to Application Insights in .NET Core 3.1 WebJob

I have an Azure Webjob developed with .NET Core 3.1. We found that calls to ILogger.LogInformation("text message") seem to do nothing - as in, there are no AppInsights entries containing &...
Scott's user avatar
  • 962
1 vote
2 answers
109 views

Why does Serilog define its own ILogger?

I want to extend my logging code to log to my database. It appears the accepted way to do this is using Serilog and Serilog.Sinks.MsSqlServer. So I've installed these packages. My understanding is ...
Jonathan Wood's user avatar
-2 votes
1 answer
656 views

Does Microsoft logger support logging to database?

I'm implementing logging in my worker services console application. I want to log to the database and maybe other places. Since everyone seems to be using Serilog, I installed the Serilog package and ...
Jonathan Wood's user avatar
2 votes
1 answer
105 views

Is there value in logging an Exception in the filter

I just read A New Pattern for Exception Logging and if it's correct, doing this makes sense. But I find the state inside the Exception handler has the passed in parameters (which is all I log) and a ...
David Thielen's user avatar
0 votes
0 answers
134 views

Using ILogger with a wrapper to use across various classes

New to C# here. I am implementing a logger for an SDK we are building. As a part of this, I am trying to implement a logger which can be used by various classes within the SDK. Hence, working on a ...
Tarun Lolla's user avatar
0 votes
2 answers
1k views

How to get an ILogger in Main() before calling builder.Build()

I followed the guidance here and here. And what I came up with is: var configuration = new ConfigurationBuilder() .AddEnvironmentVariables() .AddJsonFile($"appsettings....
David Thielen's user avatar

1
2 3 4 5