Open
Description
using System.Text;
using System.Diagnostics;
using var loggerFactory = LoggerFactory.Create(builder =>
{
builder
.AddFilter("Microsoft", LogLevel.Warning)
.AddFilter("System", LogLevel.Warning)
.AddConsole();
});
ILogger logger = loggerFactory.CreateLogger<Program>();
logger.LogInformation("Example log message");
//await Task.Delay(100);
Environment.Exit(10);
The above does not print anything unless you uncomment the delay. I wasted an hour of time trying to figure out why logging wasn't working. A console does not buffer output. What happens if my process crashes and the last few log lines are lost?
For the record, I'm just making a .net console app that would be running as a systemd service, and systemd would capture the stdout. No reason to delay the output.