Skip to content

WriteTo.File is not working after delete log directory #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rustbomber opened this issue Mar 11, 2019 · 1 comment
Closed

WriteTo.File is not working after delete log directory #87

rustbomber opened this issue Mar 11, 2019 · 1 comment

Comments

@rustbomber
Copy link

I use serilog-aspnetcore, when app startup , log write to file is working , when I delete log directory, log no longer write to file(No new log files are created)

var template = "{Timestamp:yyyy-MM-dd HH:mm:ss.ffffff} {Level:u4} {SourceContext} {Message} {Exception}{NewLine}";

  Log.Logger = new LoggerConfiguration()
                .ReadFrom.Configuration(config)
                .Enrich.FromLogContext()
                .WriteTo.Console(outputTemplate: template)
                .WriteTo.Debug(outputTemplate: template)
                .WriteTo.File(path: Path.GetFullPath("logs/log.log"), restrictedToMinimumLevel: LogEventLevel.Information, outputTemplate: template, fileSizeLimitBytes: 5242880,
                    rollingInterval: RollingInterval.Day,rollOnFileSizeLimit: true, retainedFileCountLimit: 10)
                .CreateLogger();

      try
            {
               ....
                CreateWebHostBuilder<T>(args, config).Build().Run();
            }
            catch (Exception ex)
            {
                Log.Fatal(ex, "EServer terminated unexpectedly");
            }
            finally
            {
                Log.CloseAndFlush();
            }
@nblumhardt
Copy link
Member

Hi! I think #88 fixes one case where this might occur (though if you manage to delete a log file while it's being written, no further events will be written for that rolling interval).

We'll have this out in #78 (4.1.0). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants