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
9
votes
3 answers

Install serilog and configure in an asp .net 4.7.1 webapi

I can not find any resources for installing Serilog in an ASP.Net 4.7.1 WebApi project. Can someone help me out? There are a ton of .Net Core resources but that does not help.
Jim Kiely
  • 365
  • 2
  • 6
  • 24
9
votes
3 answers

Serilog not working from configuration in asp.net core 2.2 API

public class Program { public static void Main(string[] args) { CreateWebHostBuilder(args).Build().Run(); } public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) …
Zoinky
  • 4,083
  • 11
  • 40
  • 78
9
votes
0 answers

Serilog output valid JSON to file

If someone can please help me with my Serilog configuration. I would like to know is it possible to configure the rolling file sink to always output a file with a valid JSON. The file structure has to be an array of JSON items which looks like…
magic
  • 229
  • 3
  • 6
  • 11
9
votes
3 answers

Serilog - how to make custom console output format?

I am using Serilog with serilog-sinks-console in my C# project and I am wondering how can I modify format of console output without creating whole new formatter. I just need to adjust one thing info java (slf4j/logback) like format. From…
mojmir.novak
  • 2,920
  • 3
  • 24
  • 32
9
votes
1 answer

C# - Serilog - Enrichers leaving blank entries

Figured out the basics of Serilog. Now trying to add a few enrichers so I can print username or machinename or classname, etc in the every log lines. This is the code I have so far, using System; using Serilog; using…
scorpion35
  • 944
  • 2
  • 12
  • 30
9
votes
3 answers

Serilog is logging type rather than object content

I'm new to Serilog - trying it out to see if it will help. I'm using Serilog v2 and Serilog.Sinks.MsSqlServer v5 I have the following console app code: static void Main(string[] args) { var logger = CreateLogger(); var employee…
Rob Bowman
  • 7,632
  • 22
  • 93
  • 200
9
votes
1 answer

Package restore failed. Rolling back package changes - Serilog.AspNetCore

I have an asp.net Core project and I'm trying to add a logger to it. I choose SeriLog which I used in other projects. But when I'm trying to add the "Serilog.AspNetCore" package version 2.0.0 I'm getting" Package restore failed. Rolling back…
Aviram Fireberger
  • 3,910
  • 5
  • 50
  • 69
9
votes
1 answer

How do you set up Serilog to call a stored procedure in SQL Server when logging messages?

How do you set up Serilog to call a stored procedure in SQL Server when logging messages? I see how to use the MS SQL Server sink to store messages directly in a database table, but I'd like to call a stored procedure instead.
user2023861
  • 8,030
  • 9
  • 57
  • 86
9
votes
1 answer

How can I create a Serilog enricher that reads from HttpContext.TraceIdentifier?

I've recently integrated Serilog into several .NET Standard class libraries, including some class libraries that are used by MVC 6 projects. What I'd like to do is enrich log entries with HttpContext.TraceIdentifier. I wrote an action filter that…
NathanAldenSr
  • 7,841
  • 4
  • 40
  • 51
9
votes
1 answer

Serilog SelfLog not outputting anything

I'm actually trying to troubleshoot a problem where the MSSqlServer sink isn't writing anything to my database tables. I was advised to hook up the SelfLog to see what was going on but it isn't actually outputting anything and I'm not sure if I'm…
Sinaesthetic
  • 11,426
  • 28
  • 107
  • 176
9
votes
1 answer

With SerilogWeb.Owin discontinued, is there an "official" integration?

I came across the discontinuation notice of the SerilogWeb.Owin package, and in reading the GitHub issue there was discussion about "redirecting folks somewhere" given the ~5K+ downloads of the package. But I haven't been able to figure out where…
David Rubin
  • 1,610
  • 1
  • 17
  • 28
9
votes
2 answers

Serilog GUI for desktop

Serilog is a logging library that has Sinks (adapters) to many log viewing/analysis services (like Glimpse or Loggly). That is cool but all of them require browser to see the logs. Is there a ready GUI control for desktop applications (using…
MajesticRa
  • 13,770
  • 12
  • 63
  • 77
9
votes
2 answers

How to get an enriched property in the output message when using Serilog

I'm trying to output an enriched property into the rendered message using Serilog: private static Tester GetTester() { return new Tester {Count = 7, Name = "Redmond"}; } Log.Logger = new LoggerConfiguration() .MinimumLevel.Verbose() …
Danno
  • 933
  • 4
  • 13
  • 30
8
votes
4 answers

Custom Serilog sink with injection?

I have create a simple Serilog sink project that looks like this : namespace MyApp.Cloud.Serilog.MQSink { public class MessageQueueSink: ILogEventSink { private readonly IMQProducer _MQProducerService; public…
Banshee
  • 15,376
  • 38
  • 128
  • 219
8
votes
1 answer

Serilog Elasticsearch 8 sink - Exception: Action/metadata line [1] contains an unknown parameter [_type]

Caught exception while performing bulk operation to ElasticSearch: Elasticsearch.Net.ElasticsearchClientException: Request failed to execute. Call: Status code 400 from: POST /_bulk. ServerError: Type: illegal_argument_exception Reason:…
pkofos
  • 109
  • 1
  • 6