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

Visual Studio 'Produce Single File' publish - Serilog

I have a .net5.0 console app using Serilog via the... Log.Logger = new LoggerConfiguration() .ReadFrom.Configuration(config) .CreateLogger(); All working fine in dev. When I publish using "Produce single file", the…
dizidave
  • 63
  • 4
6
votes
3 answers

Serilog ignoring LogLevel from Microsoft.Extension.Logging

I am using NET5 ASP.NET MVC application. Application is using Serilog.AspNetCore 3.4.0 for logging appsettings.json { "Logging": { "LogLevel": { "Default": "Error" } }, "Serilog": { "Using": [ "Serilog.Sinks.Console"], …
LP13
  • 30,567
  • 53
  • 217
  • 400
6
votes
3 answers

How to create a MELA.ILogger from a Serilog.ILogger for use in a .NET Standard library

I am converting a .NET Standard utility library from console logging to ILogger logging. The library consists static utility classes, and I am exposing a static ILogger property to be set by users, to point to whatever logging system they want to…
PieterV
  • 555
  • 1
  • 4
  • 18
6
votes
1 answer

Serilog dependency injection

I am trying to dependency inject Serilog into all my projects in my WebAPI project in .Net Core 3.1. In my startup.cs, I am setting up the serilog, but possibly incorrectly: I have: using Serilog; And then within: public void…
Craig
  • 18,074
  • 38
  • 147
  • 248
6
votes
1 answer

Serilog Azure Function V3

I would like to know how I can use Serilog in Azure function. I have created a startup class in my function with the following setup: var loggerConfiguration = new LoggerConfiguration() .WriteTo.Console() .CreateLogger(); …
6
votes
1 answer

How to writing logs to STDERR base on log level using Serilog

I'm using Serilog for my .netcore application and write logs to console. And all logs come to STDOUT streams, but the requirement is Error and Fatal level should come to STDERR streams. I already added "standardErrorFromLevel": "Error" to arg of…
6
votes
1 answer

Can't redirect Trace.WriteLine to Serilog using SerilogTraceListener

In one of my project (.net core 3.1), I need a way to redirect System.Diagnostics.Trace.WriteLine to Serilog file. I found the SerilogTraceListener package which seems to be the right candidate. Unfortunately until now, I haven't been able to find a…
6
votes
1 answer

serilog not writing logs into local app data folder

I am trying to write log into "LocalApplicationData" using Serilog and using below configuration, but it's not working. If I try to write in some hard code path like "path": "C:/Temp/Logs/log.txt" then this is working. How to write into local app…
user584018
  • 10,186
  • 15
  • 74
  • 160
6
votes
2 answers

Serilog Elasticsearch logs not making it to the server (but buffering correctly)

I have an ELK stack locally hosted (v7.0) on a Windows IIS web server and the logs are not making it to the server. Server is running, I can reach the reserved URL and get back the generic json package saying Elasticsearch is running and I can log…
Hershizer33
  • 1,206
  • 2
  • 23
  • 46
6
votes
1 answer

Serilog enrichment from context not working

I have a ASP .NET Core application and i am trying to enrich the Serilog logger with a property and pass it throghout method calls. I have used Serilog.Context to enrich it to no avail, the property is not present in the log. Program Log.Logger =…
Bercovici Adrian
  • 8,794
  • 17
  • 73
  • 152
6
votes
1 answer

Serilog remove $type property

I have following logger configuration new LoggerConfiguration() .ReadFrom.Configuration(configuration.GetSection("MyConfig")) .WriteTo.Console(new CompactJsonFormatter()) .Destructure.UsingAttributes() …
Pavel
  • 653
  • 2
  • 11
  • 31
6
votes
1 answer

'ILoggingBuilder' does not contain a definition for 'AddFile'

ILoggingBuilder' does not contain a definition for 'AddFile' and the best extension method overload 'FileLoggerExtensions.AddFile(ILoggerFactory, IConfigurationSection)' requires a receiver type of 'ILoggerFactory' Note the line in the code…
CompanyDroneFromSector7G
  • 4,291
  • 13
  • 54
  • 97
6
votes
1 answer

How to use serilog in a referenced class library and use with CallerMember, CallerFilePath (not asp.net core)

I am working on a WPF application and can sucessfully setup serilog and access it's static method by placing it inside App.xaml.cs, However I am wanting to also log inside the various referenced class libraries in the project. As I can't reference…
mincasoft
  • 311
  • 3
  • 10
6
votes
2 answers

How to set logs to ELK in kibana with authentication using serilog

I have set an example of my code but I'm not able to logs in kibana with authentication using serilog. Here, I have attached my code please correct it. Log.Logger = new LoggerConfiguration() .WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new…
Shubh
  • 63
  • 1
  • 9
6
votes
2 answers

serilog push property using multiple times

I have a serilog middleware class implemented as per this blog post https://blog.datalust.co/smart-logging-middleware-for-asp-net-core/ if i want to use LogContext.PushProperty several time to push various pieces of information in my logging do i…
JimmyShoe
  • 2,009
  • 4
  • 21
  • 40