diff --git a/GFramework.Core/logging/ConsoleLogger.cs b/GFramework.Core/logging/ConsoleLogger.cs
index fdd74b8..6eb0283 100644
--- a/GFramework.Core/logging/ConsoleLogger.cs
+++ b/GFramework.Core/logging/ConsoleLogger.cs
@@ -55,7 +55,7 @@ public sealed class ConsoleLogger : ILog
}
else
{
- _writer.WriteLine(logMessage);
+ _writer!.WriteLine(logMessage);
}
}
@@ -82,7 +82,7 @@ public sealed class ConsoleLogger : ILog
try
{
Console.ForegroundColor = GetColor(level);
- _writer.WriteLine(message);
+ _writer!.WriteLine(message);
}
finally
{
diff --git a/GFramework.Core/logging/Log.cs b/GFramework.Core/logging/Log.cs
index 48b93fe..4f0c9cd 100644
--- a/GFramework.Core/logging/Log.cs
+++ b/GFramework.Core/logging/Log.cs
@@ -11,7 +11,7 @@ public static class Log
///
/// 获取当前的日志记录器实例
///
- public static ILog Instance { get; private set; } = new ConsoleLogger(null, LogLevel.Info);
+ public static ILog Instance { get; private set; } = new ConsoleLogger();
///
/// 获取当前的日志配置
@@ -24,7 +24,7 @@ public static class Log
/// 要设置的日志记录器,如果为 null 则使用默认的ConsoleLogger
public static void SetLogger(ILog? logger)
{
- Instance = logger ?? new ConsoleLogger(null, LogLevel.Info);
+ Instance = logger ?? new ConsoleLogger();
}
///
diff --git a/GFramework.Core/logging/LogConfig.cs b/GFramework.Core/logging/LogConfig.cs
index a96c70e..e4f28cb 100644
--- a/GFramework.Core/logging/LogConfig.cs
+++ b/GFramework.Core/logging/LogConfig.cs
@@ -1,7 +1,3 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-
namespace GFramework.Core.logging;
///
@@ -27,7 +23,7 @@ public sealed class LogConfig
///
/// 获取或设置是否启用文件输出(默认为false)
///
- public bool EnableFile { get; set; } = false;
+ public bool EnableFile { get; set; }
///
/// 获取或设置日志文件路径(当EnableFile为true时使用)
diff --git a/GFramework.Core/logging/LoggerFactory.cs b/GFramework.Core/logging/LoggerFactory.cs
index 2521060..afe12c5 100644
--- a/GFramework.Core/logging/LoggerFactory.cs
+++ b/GFramework.Core/logging/LoggerFactory.cs
@@ -42,7 +42,11 @@ public class LoggerFactory : ILoggerFactory
{
return Create("Global");
}
-
+ ///
+ /// 创建日志记录器
+ ///
+ /// 日志类别
+ /// 日志记录器实例
private ILog CreateLogger(string category)
{
var level = _config.GetCategoryLevel(category);
@@ -57,6 +61,11 @@ public class LoggerFactory : ILoggerFactory
return consoleLogger;
}
+ ///
+ /// 创建文件日志记录器
+ ///
+ /// 日志类别
+ /// 文件日志记录器实例
private ILog CreateFileLogger(string category)
{
try
@@ -77,6 +86,7 @@ public class LoggerFactory : ILoggerFactory
}
}
+
///
/// 组合日志记录器,将日志同时输出到多个目标
///