31 lines
		
	
	
		
			843 B
		
	
	
	
		
			C#
		
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			843 B
		
	
	
	
		
			C#
		
	
	
| using Hangfire;
 | |
| using Hangfire.Dashboard;
 | |
| using IRaCIS.Core.API._PipelineExtensions.Serilog;
 | |
| using Microsoft.AspNetCore.Builder;
 | |
| using Microsoft.AspNetCore.Hosting;
 | |
| using Serilog;
 | |
| 
 | |
| namespace IRaCIS.Core.API
 | |
| {
 | |
|   
 | |
| 
 | |
|     public static class SerilogConfig
 | |
|     {
 | |
| 
 | |
|         public static void UseSerilogConfig(this IApplicationBuilder app, IWebHostEnvironment env)
 | |
|         {
 | |
|             app.UseMiddleware<RequestResponseLoggingMiddleware>();
 | |
| 
 | |
|             app.UseSerilogRequestLogging(opts
 | |
|               =>
 | |
|             {
 | |
|                 opts.MessageTemplate = "{TokenUserRealName} {TokenUserType}  {ClientIp} {RequestIP}  {Host} {Protocol} {RequestMethod} {RequestPath} {RequestBody} responded {StatusCode} in {Elapsed:0.0000} ms";
 | |
|                 opts.EnrichDiagnosticContext = SerilogHelper.EnrichFromRequest;
 | |
|             });
 | |
| 
 | |
| 
 | |
| 
 | |
|         }
 | |
|     }
 | |
| }
 |