24 lines
		
	
	
		
			758 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			758 B
		
	
	
	
		
			C#
		
	
	
	
	
	
| using Serilog;
 | |
| using Serilog.Events;
 | |
| 
 | |
| namespace KonSoft.Shared.Hosting.AspNetCore;
 | |
| 
 | |
| public static class SerilogConfigurationHelper
 | |
| {
 | |
|     public static void Configure(string applicationName)
 | |
|     {
 | |
|         Log.Logger = new LoggerConfiguration()
 | |
| #if DEBUG
 | |
|             .MinimumLevel.Debug()
 | |
| #else
 | |
|                 .MinimumLevel.Information()
 | |
| #endif
 | |
|             .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
 | |
|             .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
 | |
|             .Enrich.FromLogContext()
 | |
|             .Enrich.WithProperty("Application", $"{applicationName}")
 | |
|             .WriteTo.Async(c => c.File("Logs/logs.txt"))
 | |
|             .WriteTo.Async(c => c.Console())
 | |
|             .CreateLogger();
 | |
|     }
 | |
| } |