feat: enhance logging configuration with async file logging for SQL commands
This commit is contained in:
@@ -169,14 +169,10 @@ public static class ServiceCollectionExtensions
|
|||||||
var lockingBehavior = serviceProvider.GetRequiredService<IEntityFrameworkCoreLockingBehavior>();
|
var lockingBehavior = serviceProvider.GetRequiredService<IEntityFrameworkCoreLockingBehavior>();
|
||||||
lockingBehavior.Initialise(opt);
|
lockingBehavior.Initialise(opt);
|
||||||
|
|
||||||
// Enable SQL query logging when log level is Debug
|
|
||||||
var loggerFactory = serviceProvider.GetService<Microsoft.Extensions.Logging.ILoggerFactory>();
|
var loggerFactory = serviceProvider.GetService<Microsoft.Extensions.Logging.ILoggerFactory>();
|
||||||
if (loggerFactory != null)
|
opt.UseLoggerFactory(loggerFactory)
|
||||||
{
|
.EnableSensitiveDataLogging()
|
||||||
opt.UseLoggerFactory(loggerFactory)
|
.EnableDetailedErrors();
|
||||||
.EnableSensitiveDataLogging()
|
|
||||||
.EnableDetailedErrors();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return serviceCollection;
|
return serviceCollection;
|
||||||
|
|||||||
@@ -32,6 +32,32 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Async",
|
||||||
|
"Args": {
|
||||||
|
"configure": [
|
||||||
|
{
|
||||||
|
"Name": "File",
|
||||||
|
"Args": {
|
||||||
|
"path": "%JELLYFIN_LOG_DIR%//sql_.log",
|
||||||
|
"rollingInterval": "Day",
|
||||||
|
"retainedFileCountLimit": 3,
|
||||||
|
"rollOnFileSizeLimit": true,
|
||||||
|
"fileSizeLimitBytes": 100000000,
|
||||||
|
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level:u3}] [{ThreadId}] {SourceContext}: {Message}{NewLine}{Exception}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Filter": [
|
||||||
|
{
|
||||||
|
"Name": "ByIncludingOnly",
|
||||||
|
"Args": {
|
||||||
|
"expression": "SourceContext = 'Microsoft.EntityFrameworkCore.Database.Command'"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Enrich": [ "FromLogContext", "WithThreadId" ]
|
"Enrich": [ "FromLogContext", "WithThreadId" ]
|
||||||
|
|||||||
Reference in New Issue
Block a user