I'm interested in using the Microsoft.Extensions.Logging class for logging in a Project.
I searched for around 4 hours, watched an tutorial which was about one hour and just could not figure out how to instance a logger in C# (most tutorials use ASP.Net)
What I tried:
var loggerFactory = LoggerFactory.Create(builder =>
{
builder
.AddConsole()
.AddEventLog();
});
ILogger logger = loggerFactory.CreateLogger<Form1>();
logger.LogInformation("Example log message");
This code is copied from the Microsoft Website (with some slight changes), it dosent give me Syntax Errors or warnings, but also it just does nothing.
I allready were on those links:
- https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-3.1
- https://docs.microsoft.com/en-us/archive/msdn-magazine/2016/april/essential-net-logging-with-net-core
- https://www.tutorialsteacher.com/core/fundamentals-of-logging-in-dotnet-core
- https://www.tutorialsteacher.com/core/aspnet-core-logging And many more
I try to do this in an Winforms Application
Maybe you allready did something simular in C# and .net Core.
Thank you
ILogger<T>
. – Jeremy LakemanAddDebug()
and see if it does something? – Mike Nakis