Logging to files with Serilog in Asp.Net Core

  Рет қаралды 10,932

Codewrinkles

Codewrinkles

Күн бұрын

Пікірлер: 10
@icemanja
@icemanja Жыл бұрын
Great tutorial, simple and straight to the point.
@AchuVlogs
@AchuVlogs 2 жыл бұрын
Tried this and it’s only capturing logs with same project. If we have a class library, how can we capture the logs?
@user-rp9iis1en6h
@user-rp9iis1en6h Жыл бұрын
How to remove some property from the log, lets say when there is a error, serilog writes everything to the file. I want to configure serilog so that it does not write sourcecontext property to the file. And I want to add my own property with custom values. How to achieve it?
@hwd1978
@hwd1978 6 ай бұрын
Thank you!
@TheoTiger79
@TheoTiger79 2 жыл бұрын
Thank's a lot for this video. It is really helpful. I have also a question: I have a ASP .Net Core application and want to use Serilog with File Sink. My application has another project next to the main application project which has a Program.cs and a Startup.cs. I want to use the configured Serilog logger from the main project also in the other (regular) C# library project (i.e. log events from several projects should go into one log file). Is there a best practice on how to pass this logger to classes in different projects and use it there?
@Codewrinkles
@Codewrinkles 2 жыл бұрын
The best way to achieve this is trough dependency injection. This is a very theoretical answer, but you can register the classes where you want to log in the DI container and then inject ILogger via the constructor. But depending on the exact scenario, there are several other options: use the decorator pattern, pass the ILogger when you instantiate new objects of your classes in the other project and so on.
@TheoTiger79
@TheoTiger79 2 жыл бұрын
@@Codewrinkles Thanks a lot for your answer! Today I tried the "dependency injection"-way of doing it and it works really well. I inject using "ILoggerFactory" and I pass this to some class from other projects. In the other projects I don't have any Serilog dependencies, just using Microsoft.Extensions.Logging. Like this (I hope) I can use a different logging provider more easy in the future. Like this: "ILogger logger = logFactory.CreateLogger();" - which is called from a non-main project using the logFactory passed from the class defined in the main application project via DI - I can also see the T-specific Serilog-SourceContext in the log file.
@mouradaissani8957
@mouradaissani8957 2 жыл бұрын
Keep it up
@dev4g276
@dev4g276 2 жыл бұрын
how to add debug sink
@hwd1978
@hwd1978 6 ай бұрын
Misprint: "Overrides" instead of "Override".
龟兔赛跑:好可爱的小乌龟#short #angel #clown
01:00
Super Beauty team
Рет қаралды 65 МЛН
How it feels when u walk through first class
00:52
Adam W
Рет қаралды 24 МЛН
Logging in ASP.Net Core made easy
31:10
Codewrinkles
Рет қаралды 5 М.
Asynchronous APIs with .NET
1:02:17
Les Jackson
Рет қаралды 39 М.
Serilog ile Loglama | File - Console - Debug
35:32
Tech Buddy
Рет қаралды 11 М.
Building a .NET 6 API Using TDD
1:38:59
Wes Doyle
Рет қаралды 146 М.
You are doing .NET logging wrong. Let's fix it
25:29
Nick Chapsas
Рет қаралды 173 М.
High-performance logging in .NET, the proper way
15:56
Nick Chapsas
Рет қаралды 73 М.