You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Setup Program.cs like this:
`public class Program
{
public static void Main(string[] args)
{
IConfigurationBuilder configBuilder = new ConfigurationBuilder();
configBuilder.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
IConfiguration config = configBuilder.Build();
Log.Logger = new LoggerConfiguration()
.WriteTo.File("Logs/log-{Date}.txt", buffered: true, flushToDiskInterval: TimeSpan.FromSeconds(60))
.CreateLogger();
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseSerilog() // Set serilog as the logging provider.
.UseStartup<Startup>();
}`
Get logger via DI in some controller:
`private ILogger _logger;
public SampleDataController(ILogger<SampleDataController> logger)
{
_logger = logger;
}`
Trying to log an event: public IEnumerable<WeatherForecast> WeatherForecasts(int startDateIndex) { _logger.LogInformation("Test message"); return null; }
Expected result:
Logs are flushed to disk every minute.
Real result:
Logs are flushed right away as log method called
The text was updated successfully, but these errors were encountered:
Hi! How are you determining that the flush is immediate? The flushToDiskInterval setting only specifies when an fsync is forced; .NET and Windows/Linux may decide to flush out writes faster than that.
Reproduction steps:
Setup Program.cs like this:
`public class Program
{
public static void Main(string[] args)
{
IConfigurationBuilder configBuilder = new ConfigurationBuilder();
configBuilder.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
IConfiguration config = configBuilder.Build();
}`
Get logger via DI in some controller:
`private ILogger _logger;
Trying to log an event:
public IEnumerable<WeatherForecast> WeatherForecasts(int startDateIndex) { _logger.LogInformation("Test message"); return null; }
Expected result:
Logs are flushed to disk every minute.
Real result:
Logs are flushed right away as log method called
The text was updated successfully, but these errors were encountered: