Questions tagged [serilog-sinks-file]
86 questions
0
votes
1 answer
Injected Serilog does log to Debug, but not File
I'm trying to use Serilog with DI in my .NET 6 application. I have Serilog configured like this:
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", Serilog.Events.LogEventLevel.Information)
…

DaQookie
- 31
- 4
0
votes
0 answers
Only custom events are getting logged twice with serilog
I have a custom logger which implements serilog. Trace are getting logged once but the events are getting logged twice.
Below is the host.json:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
…

n1k1
- 51
- 6
0
votes
1 answer
Serilog: restrictedToMinimumLevel using LevelSwitches
I am using Serilog in a .Net 5 application, and I am configuring it loading the configuration from appsettings.{env}.json.
In this file I want to specify a different minimum logging level for each sink, and I would like to control it with a…

maradev21
- 576
- 2
- 6
- 20
0
votes
3 answers
How to add custom file name to serilog file sink generated logs file
I would like to add hostname to the log files which is generated by Serilog file sink.
I tried below, but my file name appears as log-{fileName}-20210910.txt for below code,
vservices.AddLogging(logging => logging.AddSerilog(
new…

user584018
- 10,186
- 15
- 74
- 160
0
votes
1 answer
Can't force Serilog.Sinks.File wrapped in Serilog.Sinks.Async to work in two-stage initialization approach
Serilog doesn't log to the File sink wrapped in Async sink when using two-step initialization with appSettings configuration. I'm using the following Serilog NuGet packages:
Serilog - 2.10.0
Serilog.Settings.Configuration - 3.1.0
Serilog.AspNetCore…

roten
- 196
- 13
0
votes
1 answer
Set maxium of Serilog rolling files
I want to know if it's possible to set a max count of rolling files?
I want to do that so I don't need to create a job to clean up old log files. Logs for the last month would be just fine.
This is my current configuration
private static…

Martin Andersen
- 2,460
- 2
- 38
- 66
0
votes
1 answer
Serilog doesn't parse file name templae
I'm using serilog with this configuration:
{
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
"MinimumLevel": "Debug",
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
…

Maxim Kitsenko
- 2,042
- 1
- 20
- 43
0
votes
0 answers
logging in the application using Serilog
Unable to fetch Serilog > SourceContext property value using code. SourceContext property is not getting generated against Properties field in log table. Trying to fetch SourceContext value of every method i.e., api, service, repository by using a…
user6937080
0
votes
1 answer
how to configure serilog and applicationinsights in App.config?
I was trying to do this to configure serilog to write to application insights. it is in app.config file. But it doesn't work. Is there any alternative approach

user15368519
- 31
- 4
-1
votes
1 answer
Temporily disable timestamp in Serilog
I'm using the package Serilog.Sinks.File I want to disable timestamp just for few messages without creating another instance of LoggerConfiguration for example-
Log.Logger = new LoggerConfiguration().WriteTo.File("logs/log.txt", outputTemplate:…

Dark Knight
- 819
- 8
- 12
-1
votes
1 answer
Unable to Delete Log when creating from Serilog.Log
I'm using .Net Core 3.1 Application which is API.
Due to below code, I'm able to generate example.txt log file however unable to delete this. "The process cannot access the file '' because it is being used by another process w3p".
Log.Logger = (new…