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

Serilog with Asp.net Web Api not using enricher

I have a Microsoft Asp.Net Web Api project, in which I am attempting to setup serilog logging. I have installed the Nuget packages for Serilog, Serilog.Sinks.File, SerilogWeb.Classic, and SerilogWeb.Classic.WebApi. Note, that I am NOT able to use…
dmoore1181
  • 1,793
  • 1
  • 25
  • 57
6
votes
2 answers

Serilog massive performance hit when enabling Debug log level

I'm using Serilog on a .NET Core Service Fabric application. We noticed performance issues and after investigation it turns out that Serilog is the culprit. We log ~2,000 Debug messages and it takes 10+ seconds. This is even with only the Console…
R4cOOn
  • 2,340
  • 2
  • 30
  • 41
6
votes
1 answer

Same log file in multiple projects using serilog

I have a Logger.cs class: public Logger(string logtype=null) { _logtype = logtype; LogEventLevel level = LogEventLevel.Warning; if (File.Exists(configPath)) { XDocument xdoc =…
Rem San
  • 367
  • 1
  • 5
  • 20
6
votes
1 answer

Logging to email sink with Serilog

I have an aspnet core app and I'm trying to configure serilog to send me emails, with no luck. I have this configuration: Log.Logger = new LoggerConfiguration() .MinimumLevel.Information() …
Evgeni
  • 3,341
  • 7
  • 37
  • 64
6
votes
1 answer

How to get Serilog to log to the web output directory from appsettings.json?

I created a new .NET Core web project using Visual Studio and integrated Serilog. It reads settings from the appsettings.json (via .UseSerilog((ctx, config) => { config.ReadFrom.Configuration(ctx.Configuration); })). In the appsettings.json, the…
AngryHacker
  • 59,598
  • 102
  • 325
  • 594
6
votes
1 answer

Using Serilog in ASP.NET MVC project

Today at work I was asked to add some basic logging functionality in my existing ASP.NET MVC (not Core) project. I was told to use Serilog for this. However, I failed to find any reasonable example of using Serilog in MVC, all links simply refer to…
6
votes
2 answers

How to create a Custom text formatter for Cloudwatch?

I don't understand how to create a custom text formatter for Amazon Cloudwatch as mentioned: var formatter = new MyCustomTextFormatter(); I am trying to write Serilog logs to Amazon CloudWatch instead of the local hard disk. To do that I am…
Salah
  • 173
  • 3
  • 17
6
votes
1 answer

How to add a custom property to ILogger

I want to add a custom property and value to an instance of ILogger obtained from ForContext. The idea being that I can tag all statements with some name, like "Render", or "AI", and then see that group name in the output and also filter on it. All…
Christopher Pisz
  • 3,757
  • 4
  • 29
  • 65
6
votes
0 answers

Send stringified json to serilog as structured data

I have: Serilog 2.7.1 .NET Framework 4.5.x I have a stringified JSON with different structures. Example: { "dto": { "id": "8d8cc96fa1b44186b28f2a90364e47d2", "userName": "case6", "display": true, "isFullUpdate": false } } I want…
Vadym
  • 111
  • 5
6
votes
2 answers

Is it possible to elegantly configure Serilog with if-statements?

My Serilog configuration code looks like this: Log.Logger = new LoggerConfiguration() .Enrich.WithExceptionDetails() .Enrich.FromLogContext() .MinimumLevel.Warning() // .MinimumLevel.Override("Microsoft", LogEventLevel.Verbose) // …
Dai
  • 141,631
  • 28
  • 261
  • 374
6
votes
2 answers

Serilog MSSQL Sink doesn't write logs to database

I have created a .Net class library (4.6.2) and created serilog implementation which is called by other interfaces such as console app. Now when I use File sink type, the logs are getting written to the files but with MSSQL sink, its not doing so.…
djSmart
  • 113
  • 1
  • 7
6
votes
2 answers

ASP.NET Core Logging - Filter out System items

I have recently set up Serilog to handle my logging activities to the database. However, when I started it up, I noticed plenty of System and Microsoft activities filling up the rows. I have tried to add several overrides in my Serilog filters but…
JianYA
  • 2,750
  • 8
  • 60
  • 136
6
votes
2 answers

Serilog Logging with ClassName, Method Name

I am using serilog and SEQ in my project Angular,web api, EF. I am new to both. 1) How can I make sure every time I write error, information, debug it should contain ClassName.Method Name. I know I have to create Enrich but not sure how to get…
itmannz
  • 529
  • 9
  • 19
6
votes
1 answer

How do I modify Serilog Log Levels to match up with Log4Net?

So I am in the process of swapping logging frameworks from Log4Net to Serilog where we log out to a text file. I want the format of the text file to be exactly the same as I had previously, so users have a seamless migration. So with the Serilog…
Warren Buckley
  • 1,291
  • 1
  • 16
  • 20
6
votes
2 answers

How to use Autofac with a Serilog wrapper class

A while ago we started to replace our logger from log4net to Serilog in order to send our logs straight to our Elastic. In our project we are working with IOC using Autofac. As so, we initially created a wrapper class (LogSerilog) and a…
Green
  • 2,405
  • 3
  • 22
  • 46