|
@@ -64,14 +64,15 @@ public static class LoggingSetup
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 日志写入数据库
|
|
|
|
|
- if (App.GetConfig<bool>("Logging:Database:Enabled", true))
|
|
|
|
|
|
|
+ // 日志写入ElasticSearch
|
|
|
|
|
+ if (App.GetConfig<bool>("Logging:ElasticSearch:Enabled", true))
|
|
|
{
|
|
{
|
|
|
- services.AddDatabaseLogging<DatabaseLoggingWriter>(options =>
|
|
|
|
|
|
|
+ services.AddDatabaseLogging<ElasticSearchLoggingWriter>(options =>
|
|
|
{
|
|
{
|
|
|
options.WithTraceId = true; // 显示线程Id
|
|
options.WithTraceId = true; // 显示线程Id
|
|
|
options.WithStackFrame = true; // 显示程序集
|
|
options.WithStackFrame = true; // 显示程序集
|
|
|
options.IgnoreReferenceLoop = false; // 忽略循环检测
|
|
options.IgnoreReferenceLoop = false; // 忽略循环检测
|
|
|
|
|
+ options.MessageFormat = LoggerFormatter.Json;
|
|
|
options.WriteFilter = (logMsg) =>
|
|
options.WriteFilter = (logMsg) =>
|
|
|
{
|
|
{
|
|
|
return logMsg.LogName == "System.Logging.LoggingMonitor"; // 只写LoggingMonitor日志
|
|
return logMsg.LogName == "System.Logging.LoggingMonitor"; // 只写LoggingMonitor日志
|
|
@@ -79,15 +80,14 @@ public static class LoggingSetup
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 日志写入ElasticSearch
|
|
|
|
|
- if (App.GetConfig<bool>("Logging:ElasticSearch:Enabled", true))
|
|
|
|
|
|
|
+ // 日志写入数据库
|
|
|
|
|
+ if (App.GetConfig<bool>("Logging:Database:Enabled", true))
|
|
|
{
|
|
{
|
|
|
- services.AddDatabaseLogging<ElasticSearchLoggingWriter>(options =>
|
|
|
|
|
|
|
+ services.AddDatabaseLogging<DatabaseLoggingWriter>(options =>
|
|
|
{
|
|
{
|
|
|
options.WithTraceId = true; // 显示线程Id
|
|
options.WithTraceId = true; // 显示线程Id
|
|
|
options.WithStackFrame = true; // 显示程序集
|
|
options.WithStackFrame = true; // 显示程序集
|
|
|
options.IgnoreReferenceLoop = false; // 忽略循环检测
|
|
options.IgnoreReferenceLoop = false; // 忽略循环检测
|
|
|
- options.MessageFormat = LoggerFormatter.Json;
|
|
|
|
|
options.WriteFilter = (logMsg) =>
|
|
options.WriteFilter = (logMsg) =>
|
|
|
{
|
|
{
|
|
|
return logMsg.LogName == "System.Logging.LoggingMonitor"; // 只写LoggingMonitor日志
|
|
return logMsg.LogName == "System.Logging.LoggingMonitor"; // 只写LoggingMonitor日志
|