You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.2 KiB

using log4net;
using log4net.Config;
namespace EC.Util.Common;
public class LogUnit
{
private static readonly ILog logger;
static LogUnit()
{
string filePath = Path.Combine("config", "log4net.config");
if (!File.Exists(filePath)) throw new FileNotFoundException(filePath);
XmlConfigurator.Configure(new FileInfo(filePath));
logger = LogManager.GetLogger(typeof(LogUnit));
}
public static void VirtualInit()
{ }
public static void Debug(string msg) => logger.Debug(msg);
public static void Info(string msg) => logger.Info(msg);
public static void Warn(string msg) => logger.Warn(msg);
public static void Fatal(string msg) => logger.Fatal(msg);
public static void Error(string msg) => logger.Error(msg);
public static void Error(Exception e) => logger.Error(e);
public static void Error(object obj, string msg) => logger.Error(obj.GetType(), new Exception(msg));
public static void Error(object obj, Exception e) => logger.Error(obj.GetType(), e);
public static void Error(Type type, string msg) => logger.Error(type, new Exception(msg));
public static void Error(Type type, Exception e) => logger.Error(type, e);
}