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

Serilog topshelf integration not working

I'm trying to set up a simple logging configuration for my Windows service using Topshelf and Serilog (the Serilog.Extras.Topshelf package respectively). HostLogger.UseLogger(new SerilogHostLoggerConfigurator(new LoggerConfiguration() …
xvdiff
  • 2,179
  • 2
  • 24
  • 47
14
votes
3 answers

Serilog logging web-api methods, adding context properties inside middleware

I've been struggling to log response body payload data with serilog, logging from middleware. I'm working on WEB API Core application, with swagger added to endpoints, and my goal is to log every endpoint call to a .json file with serilog (both…
14
votes
1 answer

Serilog in ASP.NET Core Windows Service cannot write file as Local System

I am running an ASP.NET Core web server as a Windows service and am using Serilog to log to a file in %PROGRAMDATA%. When I run the service as Local System, nothing is logged. I am using .Net Core 2.2 on Windows 10. I am testing by triggering an…
Allen Aston
  • 521
  • 5
  • 9
14
votes
3 answers

Serilog ReadFrom Configuration

I am attempting to load my Serilog configuration from appsettings.json using the Serilog.Settings.Configuration prerelease NuGet package. However when I load it using Configuration.GetSection, the value continues to come back as null. Here is what I…
j-hurst
  • 289
  • 1
  • 3
  • 12
14
votes
3 answers

How to exclude specific exception types from Serilog?

I am using Serilog to log information about an asp.net core 2.1 application hosted on IIS. When exceptions occur, I am informed by email. The thing is, some exceptions happen without hurting the application at all and I don't want to be noticed each…
Jimmy Jacques
  • 346
  • 4
  • 14
14
votes
5 answers

Serilog and .NET Core 2.1 HostBuilder Configuration

I'm using the .NET Core 2.1 HostBuilder class to set up and run a GRPC server and am having trouble getting SeriLog properly configured so that it is used by the .NET Core logging pipeline as well as available (via dependency injection) elsewhere in…
Mr. T
  • 3,892
  • 3
  • 29
  • 48
13
votes
4 answers

How to setup Serilog with Azure Functions v4 correctly?

I want to use Serilog in an Azure Function v4 (.net 6) (the logs should be sent to Datadog). For this I have installed the following nuget packages:
mikehachen
  • 256
  • 1
  • 2
  • 8
13
votes
1 answer

Is it better to use Serilog with or without Microsoft.Extensions.Logging?

I'm building an API using .NET 6 and plan to use Serilog as logger. According to https://onloupe.com/blog/serilog-vs-mel/ there are two possibilities: Use Serilog exclusively Use Microsoft.Extensions.Logging as logging API + Serilog as logging…
dario
  • 2,861
  • 3
  • 15
  • 34
13
votes
1 answer

Getting an instance of the Serilog logger without DI

I have a console app without dependency injection that uses log4net. I'm trying to replace log4net with Serilog. This is close to how log4net is setup: using log4net; using log4net.Config; using System; using System.IO; using…
Q-bertsuit
  • 3,223
  • 6
  • 30
  • 55
13
votes
2 answers

Using serilog with azure application insights and .Net core

Currently, I am using azure application insights directly for logging as given in this link Use latest version of Application Insight with .net core API and everything is working fine. But I need to use the serilog for logging now with the help of…
13
votes
1 answer

Serilog.Sinks.MSSqlServer not filling custom columns

I've looked around, but I could not find a working solution, and since all examples look alike I assume it must be me overlooking something obvious. Also note this is my first real project using.NET Core and Serilog. The Problem I am trying to log…
Ernst
  • 421
  • 4
  • 10
13
votes
3 answers

Change / override log event level in Serilog

Is there a way to change the log level of certain events dynamically? (maybe by namespace or a predicate) I'm looking for something like .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) but what I really want to do is change the level of…
Tamás Deme
  • 2,194
  • 2
  • 13
  • 31
13
votes
3 answers

Setting up Serilog to write logs to SQL Server db table

I'm trying to set up Serilog to write logs to my db table. Here's the breakdown of what I did to try and set up logging to SQL Server. 1) Install the Nuget Packages, Serilog and Serilog.Sinks.MSSqlServer 2) I set up a class called Logger.cs that…
Euridice01
  • 2,510
  • 11
  • 44
  • 76
13
votes
1 answer

Serilog structured data pretty print?

Is there a way to make Serilog format structured data into a formatted output? I've been using structured data structures in Serilog lately and even though there is an advantage of it being compact large data structures (5 properties or more) are…
jeanfrg
  • 2,366
  • 2
  • 29
  • 40
13
votes
2 answers

Does ASP.NET Core's built-in logging make NLog/Serilog/etc obsolete?

We use NLog or Serilog to do logging. We're busy porting a system from ASP.NET to ASP.NET Core, which has logging built in. Ideally, we'd like to drop NLog, as there doesn't appear to be a need for it anymore. However, is the built in logging…
grokky
  • 8,537
  • 20
  • 62
  • 96