|
|
@ -43,26 +43,25 @@ public sealed class LoggingFileComponent : IServiceComponent
|
|
|
|
return string.Format(fileName, DateTime.UtcNow);
|
|
|
|
return string.Format(fileName, DateTime.UtcNow);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
options.FileSizeLimitBytes = 5000 * 1024;
|
|
|
|
options.FileSizeLimitBytes = 5000 * 1024;
|
|
|
|
//options.MessageFormat = (logMsg) =>
|
|
|
|
options.MessageFormat = (logMsg) =>
|
|
|
|
//{
|
|
|
|
{
|
|
|
|
// var stringBuilder = new StringBuilder();
|
|
|
|
var stringBuilder = new StringBuilder();
|
|
|
|
// stringBuilder.AppendLine("【日志级别】:" + logMsg.LogLevel);
|
|
|
|
stringBuilder.AppendLine($"[{logMsg.LogLevel}] [{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffff")}] [{logMsg.LogName}] [{System.Threading.Thread.CurrentThread.ManagedThreadId}] ");
|
|
|
|
// stringBuilder.AppendLine("【日志时间】:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
stringBuilder.AppendLine($" {logMsg.Message}");
|
|
|
|
// stringBuilder.AppendLine("【日志内容】:" + logMsg.Message);
|
|
|
|
if (logMsg.Exception != null)
|
|
|
|
// if (logMsg.Exception != null)
|
|
|
|
{
|
|
|
|
// {
|
|
|
|
stringBuilder.AppendLine(logMsg.Exception.Message);
|
|
|
|
// stringBuilder.AppendLine("【异常信息】:" + logMsg.Exception);
|
|
|
|
stringBuilder.AppendLine(logMsg.Exception.StackTrace);
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// stringBuilder.AppendLine("【ManagedThreadId】:" + System.Threading.Thread.CurrentThread.ManagedThreadId);
|
|
|
|
|
|
|
|
|
|
|
|
if (logMsg.Context != null && logMsg.Context.Properties != null && logMsg.Context.Properties.Count > 0)
|
|
|
|
// if (logMsg.Context != null && logMsg.Context.Properties != null && logMsg.Context.Properties.Count > 0)
|
|
|
|
{
|
|
|
|
// {
|
|
|
|
foreach (var prop in logMsg.Context.Properties)
|
|
|
|
// foreach (var prop in logMsg.Context.Properties)
|
|
|
|
{
|
|
|
|
// {
|
|
|
|
stringBuilder.AppendLine($"{prop.Key}:{prop.Value}");
|
|
|
|
// stringBuilder.AppendLine($"【属性】{prop.Key}:{prop.Value}");
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
return stringBuilder.ToString();
|
|
|
|
// return stringBuilder.ToString();
|
|
|
|
};
|
|
|
|
//};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|