question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

when serilog is writing the log into file,i cant open that file

See original GitHub issue

this is my code, who can tell me how to set the serilog

Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .MinimumLevel.Information() .MinimumLevel.Override("Microsoft", LogEventLevel.Information) .Enrich.FromLogContext() .WriteTo.Console() // .WriteTo.Async(c => c.File("Logs/logs.txt")) .WriteTo.Logger(lg => lg.Filter.ByIncludingOnly(p => p.Level == LogEventLevel.Debug).WriteTo.File(LogFilePath("Debug"), rollingInterval: RollingInterval.Day, outputTemplate: SerilogOutputTemplate)) .WriteTo.Logger(lg => lg.Filter.ByIncludingOnly(p => p.Level == LogEventLevel.Information).WriteTo.File(LogFilePath("Information"), rollingInterval: RollingInterval.Day, outputTemplate: SerilogOutputTemplate)) .WriteTo.Logger(lg => lg.Filter.ByIncludingOnly(p => p.Level == LogEventLevel.Warning).WriteTo.File(LogFilePath("Warning"), rollingInterval: RollingInterval.Day, outputTemplate: SerilogOutputTemplate)) .WriteTo.Logger(lg => lg.Filter.ByIncludingOnly(p => p.Level == LogEventLevel.Error).WriteTo.File(LogFilePath("Error"), rollingInterval: RollingInterval.Day, outputTemplate: SerilogOutputTemplate)) .WriteTo.Logger(lg => lg.Filter.ByIncludingOnly(p => p.Level == LogEventLevel.Fatal).WriteTo.File(LogFilePath("Fatal"), rollingInterval: RollingInterval.Day, outputTemplate: SerilogOutputTemplate)) .CreateLogger();

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
bartelinkcommented, Apr 24, 2020

You can’t delete a file that’s been locked for writing. There may be a way to tell the File sink not to hold the file open (please DO NOT ENGAGE ME IN CHAT HERE REGARDING THAT!). It’s possible that VS has a Read Only mode that will work even if the file is locked. Visual Studio WILL work. And I will now Work too. Again: Stackoverlow.com please.

1reaction
bartelinkcommented, Apr 24, 2020

I often use Visual Studio Code in the background to view the log file - the log writer will attempt to open the file in Write mode, and the Operating System will prevent more than one thing from doing that; this is likely part of your problem. I hope you got sorted.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Serilog not writing to file
To use the file sink with Microsoft.Extensions.Configuration , for example with ASP.NET Core or .NET Core, use the Serilog.Settings.
Read more >
Serilog not writing to expected file - Microsoft Q&A
I am new to Serilog. Need to understand below scenario: Third party application invokes two different .net custom controls at the same time....
Read more >
How to Configure Rolling File Logging With Serilog
A comprehensive walkthrough of how to configure rolling file logging with Serilog using file sink and various policies in C#.
Read more >
Serilog — simple .NET logging with fully-structured events
Flexible, structured events — log file convenience.
Read more >
Serilog Tutorial for .NET Logging: 16 Best Practices and Tips
Serilog makes it easy to record custom object properties and output your logs to JSON. Read this Serilog tutorial for best practices and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found