From ac3439499f3c8270f4c4f5f3f2fbc5ccf985a94d Mon Sep 17 00:00:00 2001 From: GZTime Date: Tue, 8 Nov 2022 16:11:13 +0800 Subject: [PATCH] chore: update logger --- GZCTF/Program.cs | 2 -- GZCTF/Utils/LogHelper.cs | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/GZCTF/Program.cs b/GZCTF/Program.cs index 3fabb6ca8..12f1da9ec 100644 --- a/GZCTF/Program.cs +++ b/GZCTF/Program.cs @@ -43,8 +43,6 @@ builder.Configuration.AddEnvironmentVariables("GZCTF_"); Log.Logger = LogHelper.GetInitLogger(); -Log.Logger.Debug("GZCTF 正在启动中……"); - #endregion Logging #region AppDbContext diff --git a/GZCTF/Utils/LogHelper.cs b/GZCTF/Utils/LogHelper.cs index 0f3597bd5..4391a67e0 100644 --- a/GZCTF/Utils/LogHelper.cs +++ b/GZCTF/Utils/LogHelper.cs @@ -93,6 +93,7 @@ public static void Log(this ILogger _logger, string msg, string uname, str }; private const string LogTemplate = "[{@t:yy-MM-dd HH:mm:ss.fff} {@l:u3}] {Substring(SourceContext, LastIndexOf(SourceContext, '.') + 1)}: {@m} {#if Length(Status) > 0}#{Status} <{UserName}>{#if Length(IP) > 0}@{IP}{#end}{#end}\n{@x}"; + private const string InitLogTemplate = "[{@t:yy-MM-dd HH:mm:ss.fff} {@l:u3}] {@m}\n{@x}"; public static Logger GetInitLogger() => new LoggerConfiguration() @@ -103,7 +104,7 @@ public static Logger GetInitLogger() .MinimumLevel.Override("Microsoft.Hosting.Lifetime", LogEventLevel.Information) .MinimumLevel.Override("Microsoft.Hosting.Lifetime", LogEventLevel.Warning) .WriteTo.Async(t => t.Console( - formatter: new ExpressionTemplate(LogTemplate, theme: TemplateTheme.Literate), + formatter: new ExpressionTemplate(InitLogTemplate, theme: TemplateTheme.Literate), restrictedToMinimumLevel: LogEventLevel.Debug )) .CreateLogger();