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.
		
		
		
		
			
				
					67 lines
				
				1.2 KiB
			
		
		
			
		
	
	
					67 lines
				
				1.2 KiB
			| 
								 
											3 years ago
										 
									 | 
							
								using log4net;
							 | 
						||
| 
								 | 
							
								using log4net.Config;
							 | 
						||
| 
								 | 
							
								using System;
							 | 
						||
| 
								 | 
							
								using System.IO;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								namespace System;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								public static class LogUnit
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    private static readonly ILog logger;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    static LogUnit()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        string fileName = Path.Combine("config", "log4net.Config");
							 | 
						||
| 
								 | 
							
								        XmlConfigurator.Configure(new FileInfo(fileName));
							 | 
						||
| 
								 | 
							
								        logger = LogManager.GetLogger(typeof(LogUnit));
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    public static void Init()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    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 Error(string msg)
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        logger.Error(msg);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    public static void Fatal(string msg)
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        logger.Fatal(msg);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    public static void Error(Exception e)
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        logger.Error(e);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    /// <summary>
							 | 
						||
| 
								 | 
							
								    /// 输出日志到Log4Net
							 | 
						||
| 
								 | 
							
								    /// </summary>
							 | 
						||
| 
								 | 
							
								    /// <param name="t"></param>
							 | 
						||
| 
								 | 
							
								    /// <param name="ex"></param>
							 | 
						||
| 
								 | 
							
								    public static void Error(Type t, Exception ex)
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								       
							 | 
						||
| 
								 | 
							
								        logger.Error("Error", ex);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    public static void Error(Type t, string logMessage)
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        logger.Error(logMessage);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 |