Skip to content

Instantly share code, notes, and snippets.

@sunnamed434
Created January 15, 2023 13:11
Show Gist options
  • Save sunnamed434/50e03c8f24c7492b43e81b13a0463029 to your computer and use it in GitHub Desktop.
Save sunnamed434/50e03c8f24c7492b43e81b13a0463029 to your computer and use it in GitHub Desktop.
var currentAssemblyDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
var fileFormat = string.Format(Path.Combine(currentAssemblyDirectory, "logs", "bitmono-{0:yyyy-MM-dd-HH-mm-ss}.log"), DateTime.Now).Replace("\\", "/");
var loggerConfiguration = new LoggerConfiguration()
.Enrich.FromLogContext()
.WriteTo.Async(configure =>
{
configure.File(fileFormat, rollingInterval: RollingInterval.Infinite, restrictedToMinimumLevel: LogEventLevel.Information,
outputTemplate: "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}][{SourceContext}] {Message:lj}{NewLine}{Exception}");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment