Questions tagged [serilog]

Serilog is a .NET library which provides diagnostic logging to files, the console, and so-on. Consider using this tag along with the .net framework version you are using for extra clarity

Serilog is a library that provides diagnostic logging to files, the console, and so-on. It is easy to set up, has a clean API, and is portable between recent .NET platforms.

Unlike other logging libraries for .NET, Serilog is built with structured log data in mind. Parameters passed along with log messages are not destructively rendered into a text format. Instead, they're preserved as structured data that can be written in document form to a data store.

Useful links

2233 questions
7
votes
2 answers

Cannot resolve ILogger Simple Injector ASP.NET Core 2.0

We use Simple Injector in ASP.NET Core application. Recently we've decided to use Serilog for logging purposes. Configuration was done in Program.cs as stated in their documentation. Then, in order to make Simple Injector able to resolve…
managerger
  • 728
  • 1
  • 10
  • 31
7
votes
1 answer

Serilog - AppSettings for Application name

I am trying to read the application name from the App.Config. This is net461 console app. I have added the Serilog.Settings.AppSettings package. And also added the following serilog configs on App.Config
MJK
  • 3,434
  • 3
  • 32
  • 55
7
votes
2 answers

Serilog serializing fields

If I have the following class public class Customer { public string Name; } and then have the following log command in Serilog Log.Logger = new LoggerConfiguration() .WriteTo.Console() .WriteTo.Seq("http://localhost:5341") …
Craig
  • 36,306
  • 34
  • 114
  • 197
7
votes
3 answers

How can I lower the log level of the mvc pipeline in aspnetcore?

So in an ASPNETCORE 2.0 project, I added a logging provider (serilog) to the logging factory along with a console sink. It works great, however I noticed that all the framework request pipelines (like http request response) are logging every little…
Sinaesthetic
  • 11,426
  • 28
  • 107
  • 176
7
votes
3 answers

What file name placeholders are available for Serilog?

I use Serilog on a .NET Core application with RollingFile. I wonder, if there are different filename placeholders? I only know {Date}. For example, I have code like Log.Logger = new LoggerConfiguration() …
Kim
  • 150
  • 1
  • 2
  • 7
7
votes
2 answers

Mvvm-light / Serilog design time error: Could not load file or assembly [VS2017]

I'm getting the error below in DesignTime when I have a view open which has a viewmodel with references to SeriLog. Could not load file or assembly 'Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10' or one of its …
Jasper
  • 444
  • 3
  • 19
7
votes
1 answer

Serilog: Open log file

Is there a way to get the full filename from the Log Class? The logger creates a file with a format like C:\MyPath\log-20160631.txt I can not access the source filename which i used for the init of the logger. Edit: Here is the init of the…
Suplanus
  • 1,523
  • 16
  • 30
7
votes
1 answer

Implementation and usage of logger wrapper for Serilog

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
7
votes
1 answer

Serilog "Maximum destructuring depth reached"

I've enabled SeriLog (latest version) Self-Logging and am seeing hundreds of messages that say Maximum destructuring depth reached No idea what that means and whether it's a problem I need to worry about or not. Does anyone know what triggers…
Mr. T
  • 3,892
  • 3
  • 29
  • 48
7
votes
1 answer

Write Serilog logs directly to ElasticSearch

I want to setup a log aggregator. So far I'm leaning towards ElasticSearch/Kibana. In my apps I'm using Serilog, that currently writes to the Windows Event Log. How do I configure Serilog to send the logs to ElasticSearch instead?
john_mm
  • 91
  • 1
  • 4
6
votes
2 answers

Serilog Level switcher via api endpoint

I am using Serilog for logging in my .net 6 web api and would like to expose an endpoint to enable me to change the global logging level. This will enable me to switch the level via a front end toggle switch. This is what I have implemented so far…
Mark Redfern
  • 357
  • 1
  • 3
  • 24
6
votes
1 answer

Serilog and log injection

After searching for a long time, I couldn't find information about how Serilog deals with the sanitization of log feeds. A.k.a. the battle against "log injection" or "log forging" (see https://owasp.org/www-community/attacks/Log_Injection). All the…
6
votes
0 answers

Is there a JSON schema for Serilog?

We exclusively use appsettings.json (and environment specific versions) to configure Serilog. I'd love to have intellisense when configuring Serilog in those files. Does anybody know if they have a schema or if someone has created one and shared it?
sliderhouserules
  • 3,415
  • 24
  • 32
6
votes
2 answers

Configure Serilog with WebApplicationBuilder in Net 6

I Net Core 5 I used to configure Serilog using the recommended approach: public static void Main(string[] args) { Log.Logger = new LoggerConfiguration().WriteTo.Console().CreateLogger(); try { Log.Information("Starting up"); …
Miguel Moura
  • 36,732
  • 85
  • 259
  • 481
6
votes
3 answers

Serilog does not output logs into the txt file

Im using dotnet worker service (.net 5) I integrated serilog as well as enrichers and sinks. But for some reason I dont see any outputs into my files logs. Here is my appsettings.json { "ConnectionStrings": { "DefaultConnection":…
Stefan0309
  • 1,602
  • 5
  • 23
  • 61