Questions tagged [microsoft-extensions-logging]
53 questions
41
votes
4 answers
Use NLog in ASP.NET Core application
I found a CodeProject with an example of how to get this to work, but it doesn't work. The main problem seems to be that the "Microsoft.Framework.Logging.NLog": "1.0.0-*" package doesn't seem to exist in Nuget. I've looked at this StackOverflow…

peinearydevelopment
- 11,042
- 5
- 48
- 76
26
votes
2 answers
Microsoft.Extensions.Logging Vs. NLog
I see a lot of posts mentioning usage of Microsoft.Extensions.Logging together with NLog.
I'd like to better understand what Microsoft.Extensions.Logging is used for?
And specifically why is it needed or what's the benefit of using it together…

AlexVPerl
- 7,652
- 8
- 51
- 83
21
votes
2 answers
Simple Injector: Register ILogger by using ILoggerFactory.CreateLogger()
I'm working with a project which utilizes Simple Injector as dependency injector. On the other hand, this project uses Microsoft.Extensions.Logging in order to log the events that occurs in certain classes.
My technical issue is pretty simple to…

Mauro Bilotti
- 5,628
- 4
- 44
- 65
13
votes
1 answer
netcore not logging to console
I have a simple test project to experiment with logging with NetCore 2.0 using the Microsoft Logging Extensions package.
The problem I'm having is that when I run my app the very first time, it logs informational messages as expected. The weird…

ajawad987
- 4,439
- 2
- 28
- 45
10
votes
0 answers
Setting logging scope globally in ASP.Net Core
I want to get certain key bits of information (service-name, service-version, host-name, etc) logged on every log message in an ASP.Net Core service.
I have the following code:
public class Program
{
public static void Main(string[] args)
{
…

RB.
- 36,301
- 12
- 91
- 131
9
votes
3 answers
Serilog only logs first element of array
I'm using Serilog 2.10.0 for logging in an ASP.NET Core Application on .NET 5. I'm running into a problem when trying to log an event where there is only one parameter and this parameter is an array. The following is some example code and the log…

Fabian
- 439
- 3
- 9
9
votes
2 answers
How to include logging scope into the log file using NLog
I'm using NLog.Extensions.Logging.
When registering a logger factory using the method AddNLog(), it is possible to enable logging scope using NLogProviderOptions.IncludeScopes.
But how to make NLog write logging scope to a file?
I haven't…

Sergun
- 93
- 1
- 5
9
votes
1 answer
Can Serilog destructure complex objects passed to BeginScope?
I'm using Serilog.Extensions.Logging and outputting to console with this outputTemplate:
"{Timestamp:HH:mm} [{Level:u3}] {Message} {Properties:j} {NewLine}"
What I would like to see, is that complex objects set via BeginScope get destructured into…

AroglDarthu
- 1,021
- 8
- 17
9
votes
1 answer
asp.net mvc core The call is ambiguous between the following methods or properties:
I am working on an application, and I got an error in Startup.cs partial classes, and I cant find why this error shows up:
The call is ambiguous between the following methods or properties:…

Wasyster
- 2,279
- 4
- 26
- 58
6
votes
1 answer
Application Insights not logging with Azure Functions C#. Namespace seems the problem
Our function delegates all the logic to another class "CreateHandler" where we use the ILogger through DI. The function logs properly but the CreateHandler does not. Locally we verified that it does not log to the console, UNLESS we change the class…

user33276346
- 1,501
- 1
- 19
- 38
6
votes
2 answers
How to log to database using the built-in Asp.Net core logging (Microsoft.Extensions.Logging)?
I have the following code to set up logging to database using NLog. I use an Alpha version of NLog.Extension.Logging. Is it possible to let the built-in log framework log to database so I don't need to use NLog?
public void…

ca9163d9
- 27,283
- 64
- 210
- 413
6
votes
2 answers
Asp.Net 5 (core) RC1: How to log to file (rolling file logging) [DNX Core 5 compatible solution]?
How can I log to file in Asp.Net 5 RC1? I couldn't find any solution with Microsoft.Extensions.Logging. Is there any solution which is compatible with .Net Core 5 (DNX Core 5.0)? I also was trying to use Serilog but Serilog doesn't support core 5…

stratever
- 586
- 4
- 11
5
votes
2 answers
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 meantime we need somehow to convert our…

maradev21
- 576
- 2
- 6
- 20
5
votes
1 answer
How to add ThreadId and ProcessId into the log output for each entry
is there a simple way to add ThreadId and ProcessId into the logs through Microsoft.Extensions.Logging without writing my own LoggingProvider?
Simply following code
Logger.LogInformation("This is a test of the emergency broadcast system.");
should…

cilerler
- 9,010
- 10
- 56
- 91
5
votes
2 answers
Implementation and usage of logger wrapper for Microsoft.Extensions.Logging
This question is related to Steven’s answer - here. He proposed a very good logger wrapper. I will paste his code below:
public interface ILogger
{
void Log(LogEntry entry);
}
public static class LoggerExtensions
{
public static void…

Steven
- 166,672
- 24
- 332
- 435