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

What does "Using" in Serilog JSON configuration do?

What does actually Using do in Serilog JSON configuration (e.g. in AppSettings.json file in .Net Core environment)? Let us take this configuration for example: "Serilog": { "Using": [ "Serilog.Sinks.Console" ], <=======***HERE***========= …
Mohammed Noureldin
  • 14,913
  • 17
  • 70
  • 99
10
votes
1 answer

Creating a serilog file sink later at runtime - how?

I use Serilog on the server side for all my .NETCore services using console, file and Graylog sinks. I also like to use it in my Windows fat clients (WPF applications). With the latter I have a problem since I do not see, how I can add another file…
ThommyB
  • 1,456
  • 16
  • 34
10
votes
2 answers

Is it a good idea to use serilog to write logs directly to the elasticsearch

I'm evaluating different options about the distributed log server. In the Java world, as I can see, the most popular solution is filebeat + kafka + logstash + elasticsearch + kibana. However, in .NET world, there's a serilog which can send…
Charlie
  • 2,141
  • 3
  • 19
  • 35
10
votes
3 answers

How to have different log types using Serilog and ElasticSearch

I am currently trying to change our system configuration to work with Serilog (instead of working with FileBeat as a shipper to LogStash) We are also working with the log type field (which is easy to configure in the FileBeat config file) in our…
Green
  • 2,405
  • 3
  • 22
  • 46
10
votes
1 answer

Serilog MSSqlServer sink not writing to table

I have the following statement in my Startup.cs: Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.ColoredConsole() .WriteTo.MSSqlServer("Server=(localdb)\\MSSQLLocalDB;Database=myDb.Logging;Trusted_Connection=True;",…
Ricky Hicks
  • 152
  • 1
  • 9
10
votes
2 answers

How do I write Serilog events to a .NET collection?

I want to write Serilog Warning events to a .NET collection so they can be included in a report to the user. How do I configure the static Log.Logger to write to something like a static List ? I saw the Rx Observer in the list of provided…
CAD bloke
  • 8,578
  • 7
  • 65
  • 114
9
votes
3 answers

Error loading Serilog from IConfiguration in Azure Function

I'm getting the following error when trying to setup Serilog from IConfiguration in an Azure Function. Could not load file or assembly 'Microsoft.Extensions.DependencyModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The…
Rui
  • 175
  • 8
9
votes
3 answers

Serilog only logs first element of array

I'm using Serilog 2.10.0 for logging in an ASP.NET Core Application on .NET 5. I'm running into a problem when trying to log an event where there is only one parameter and this parameter is an array. The following is some example code and the log…
Fabian
  • 439
  • 3
  • 9
9
votes
2 answers

How roll Serilog text files similar to log4net?

I wounder how to setup Serilog.Sinks.File to produce this: log.txt <-- current log log20200704.txt <-- rolled over yesterday log log20200703.txt instead of: log20200705.txt <-- current log log20200704.txt <-- rolled over yesterday…
Anton Krouglov
  • 3,077
  • 2
  • 29
  • 50
9
votes
2 answers

Serilog, Change the loglevel at runtime for a specific namespace (> MinimumLevel)

This is my default Serilog configuration SeriLogLevelSwitch.MinimumLevel = LogEventLevel.Information; Log.Logger = new LoggerConfiguration() .MinimumLevel.ControlledBy(SeriLogLevelSwitch) .MinimumLevel.Override("Microsoft",…
Marco
  • 337
  • 3
  • 10
9
votes
1 answer

Can Serilog destructure complex objects passed to BeginScope?

I'm using Serilog.Extensions.Logging and outputting to console with this outputTemplate: "{Timestamp:HH:mm} [{Level:u3}] {Message} {Properties:j} {NewLine}" What I would like to see, is that complex objects set via BeginScope get destructured into…
AroglDarthu
  • 1,021
  • 8
  • 17
9
votes
3 answers

How to add a serilog logger to a GenericHost Project in C#

I am using generic host pattern in my project. I need a logger to file specially a rolling file like Serilog. How can I add it to certain logger configuration to the host builder. In generic host we can add log configuration such as debugger and…
Hassan Ahmadi
  • 626
  • 5
  • 14
9
votes
1 answer

Multiple Serilog Loggers

Is it possible to have multiple serilog loggers? Currently within my WebApi I can call Log.Information for example to log an information event, but is there a way that I can instead make different logs and call ExternalLog.Information or…
dmoore1181
  • 1,793
  • 1
  • 25
  • 57
9
votes
1 answer

Serilog PushProperty in appsettings-configuration not working

ASP.NET Core 2.2.0 | Serilog.AspNetCore 2.1.1 | Serilog.Sinks.File 4.0.0 I'm initializing Serilog in Program.cs, reading the configuration from appsettings.json and adding middleware in Startup.cs -> Configure. Some snippets: Program.cs public…
CribAd
  • 452
  • 6
  • 19
9
votes
4 answers

Azure Function failing to initialise Serilog Sink when using appsettings.json

I've created a simple Azure Function with the intension of using Serililog for logging to Azure Blob Storage. When using inline configuration for the Serilog sink, that works perfectly fine, the sink is created and Serilog happily wirtes to Blob…
O'Neil Tomlinson
  • 702
  • 1
  • 6
  • 28