mh_frame_sps/APT.Infrastructure.Core/Logging/LoggerManager.cs

36 lines
910 B
C#
Raw Permalink Normal View History

2026-04-07 13:47:52 +08:00
using System.Collections.Concurrent;
namespace APT.Infrastructure.Core
{
/// <summary>
/// Logger管理器
/// </summary>
public static class LoggerManager
{
private static readonly ConcurrentDictionary<string, ILog4netLogger> Loggers;
private static readonly object LockObj = new object();
static LoggerManager()
{
Loggers = new ConcurrentDictionary<string, ILog4netLogger>();
}
public static ILog4netLogger GetLogger()
{
return GetLogger("Application");
}
public static ILog4netLogger GetLogger(string name)
{
ILog4netLogger logger;
if (Loggers.TryGetValue(name, out logger))
{
return logger;
}
logger = new Log4netLogger(name);
Loggers[name] = logger;
return logger;
}
}
}