Questions tagged [iloggerfactory]
17 questions
11
votes
4 answers
How to get ILoggerFactory in .net 6
In .Net5 ILoggerFactory is used as Configure function in Startup.cs as follows :
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
//here we used loggerFactory
…

Faraz Ahmed
- 1,467
- 2
- 18
- 33
3
votes
0 answers
Logging to elastic search with serilog and ILogger
I have written a function to return an ILogger instance. This way I can get consistent logging in all my code.
My problem is that when called from different types of runtimes/programs the logging sometimes fails with some runtimes! I.e. if I use…

Jeppe
- 1,424
- 2
- 15
- 36
2
votes
1 answer
How to get ILoggerFactory instance in .NET 6 Program.cs class
In .NET 5 ILoggerFactory can be accessed in the Startup constructor as follows:
public Startup(
IConfiguration configuration,
IHostEnvironment hostEnvironment,
ILoggerFactory loggerFactory)
{
LoggerFactory = loggerFactory;
…

Camilo Torres C.
- 23
- 1
- 4
2
votes
1 answer
Capture ILogger logs of an asp.net core application on an azure app service
I am working on an asp.net core web application.
This application is hosted on an azure app service.
This application generates log on standard output (dotnet run command). This log comes from ILogger.
How can i see this logs in azure portal…

Bob5421
- 7,757
- 14
- 81
- 175
2
votes
2 answers
Unit Testing Static Methods with ILogger in C# ILoggerFactory is Null
everyone,
I'm trying to do unit tests of my code, however I'm not able to get the ILoggerFactory to work
This is my unit test code (it may not be correct):
using NUnit.Framework;
using Microsoft.Extensions.Logging;
using System.Reflection;
using…

Stornu2
- 2,284
- 3
- 27
- 47
1
vote
3 answers
How to configure ILoggerFactory in .NET 6
In .NET 5 Startup.cs class there is Configure method which it's inside ILoggerFactory interface is injected. See below:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
…

Zohidbek Mengliboyev
- 156
- 11
1
vote
1 answer
How LoggerFactory in Dotnet core gets called
I created a sample ConsoleApp in Dotnet core 3.1 and added the Microsoft.Logging.Extension.Abstractions(5.0.0) package in it.
I also used Microsoft.Extensions.DependencyInjection(6.0.0) and set up ServiceCollection as:
var container = new…

GPuri
- 495
- 4
- 11
1
vote
1 answer
Debug and trace logs not printed when using Nlog and ILoggerFactory in .NetCore console app
Debug and Trace logs not printed although minlevel set to Trace on appsettings.json.
actual…

Yaniv daye
- 73
- 7
0
votes
2 answers
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()
…

David Thielen
- 28,723
- 34
- 119
- 193
0
votes
0 answers
Custom logger using a service needs same instance
I wrote a custom logger using the ILoggingBuilder and the ILoggerProvider pattern as describe in the .net documentation
My logger needs a service build in the app, I was able to pass the service using the ServiceProvider but unfortunetly the…

Theo
- 473
- 8
- 20
0
votes
0 answers
Logged messages are not published when running Api tests
I am having an issue getting logs that are written to the logger during an test runs to actually be written out to the console unless the corresponding WebApplicationFactory is created and disposed between tests runs...which isn't really that…

Heinrich
- 2,144
- 3
- 23
- 39
0
votes
0 answers
Always create a new ILogger or store them?
I have written a middleware for my web application.
The middleware handles special requests and writes multiple information from multiple sources to the log. For example like the following code snippet:
public class MyMiddleware
{
public async…

NCC-2909-M
- 709
- 1
- 7
- 15
0
votes
0 answers
How to use the Microsoft.Extensions.Logging.ApplicationInsights package to create an ILogger instance for AppInsights inside a .NET Framework WebForms
We are having a .NET 4.7.2 WebForms project that needs to consume a library. That library is also consumed by another application which is based on the Core platform i.e. .NET 6.0
We want to pass an ILogger instance to the library class from both…

Jatin
- 83
- 7
0
votes
0 answers
Read Logging category filters from database instead of appsettings.json file
I prefer to configure my application in just one location. For me this means having all configuration settings in my database. So I try to move my Logging configuration from the appsettings.json to my database. In my database i have added a table…

Williwyg
- 651
- 5
- 3
0
votes
0 answers
Logging to Database using Custom Logger Provider in Blazor Server
I'd like to log any Ilogger data into database in Blazor Server. So according to this video I created this repository.
When I run the project, the first page of the project is displayed for a while, but it closes suddenly. As far as I understand,…

Arani
- 891
- 7
- 18