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.
103 lines
2.6 KiB
103 lines
2.6 KiB
using System; |
|
using System.IO; |
|
using System.Reflection; |
|
using System.Xml; |
|
using log4net; |
|
using log4net.Config; |
|
|
|
namespace Common |
|
{ |
|
// Token: 0x0200004A RID: 74 |
|
public static class LogAPI |
|
{ |
|
// Token: 0x0600026D RID: 621 RVA: 0x0000EB94 File Offset: 0x0000CD94 |
|
static LogAPI() |
|
{ |
|
try |
|
{ |
|
LogAPI.Configure(); |
|
} |
|
catch (Exception ex) |
|
{ |
|
} |
|
} |
|
|
|
// Token: 0x170000D4 RID: 212 |
|
// (get) Token: 0x0600026E RID: 622 RVA: 0x0000EC0C File Offset: 0x0000CE0C |
|
private static ILog Log |
|
{ |
|
get |
|
{ |
|
return LogAPI.m_log; |
|
} |
|
} |
|
|
|
// Token: 0x0600026F RID: 623 RVA: 0x0000EC23 File Offset: 0x0000CE23 |
|
public static void Debug(string sInfo) |
|
{ |
|
LogAPI.m_log.Error(sInfo); |
|
} |
|
|
|
// Token: 0x06000270 RID: 624 RVA: 0x0000EC34 File Offset: 0x0000CE34 |
|
public static void Debug(Exception e) |
|
{ |
|
LogAPI.Debug("Message : " + e.Message); |
|
LogAPI.Debug("Source : " + e.Source); |
|
LogAPI.Debug("StackTrace : " + e.StackTrace); |
|
LogAPI.Debug("TargetSite : " + e.TargetSite); |
|
} |
|
|
|
// Token: 0x06000271 RID: 625 RVA: 0x0000EC9C File Offset: 0x0000CE9C |
|
private static void Configure() |
|
{ |
|
XmlDocument xmlDocument = new XmlDocument(); |
|
string text = LogAPI.GetAssemblyPath(); |
|
if (!text.EndsWith("\\")) |
|
{ |
|
text += "\\"; |
|
} |
|
string path = text + LogAPI.LOG_DIR; |
|
if (!Directory.Exists(path)) |
|
{ |
|
Directory.CreateDirectory(path); |
|
} |
|
string value = text + LogAPI.LOG_FILE; |
|
text += "log4net_config.xml"; |
|
xmlDocument.Load(text); |
|
XmlElement documentElement = xmlDocument.DocumentElement; |
|
XmlNode xmlNode = documentElement.SelectSingleNode("descendant::appender[@name='LogFileAppender']/file"); |
|
XmlAttributeCollection attributes = xmlNode.Attributes; |
|
attributes[0].Value = value; |
|
XmlConfigurator.Configure(documentElement); |
|
} |
|
|
|
// Token: 0x06000272 RID: 626 RVA: 0x0000ED4C File Offset: 0x0000CF4C |
|
public static string GetAssemblyPath() |
|
{ |
|
string text = Assembly.GetExecutingAssembly().CodeBase; |
|
text = text.Substring(8, text.Length - 8); |
|
string[] array = text.Split(new char[] |
|
{ |
|
'/' |
|
}); |
|
string text2 = ""; |
|
for (int i = 0; i < array.Length - 1; i++) |
|
{ |
|
text2 = text2 + array[i] + Path.DirectorySeparatorChar; |
|
} |
|
return text2; |
|
} |
|
|
|
// Token: 0x040001A6 RID: 422 |
|
private const string LOG4NET_CONFIG = "log4net_config.xml"; |
|
|
|
// Token: 0x040001A7 RID: 423 |
|
private static readonly string LOG_DIR = "日志"; |
|
|
|
// Token: 0x040001A8 RID: 424 |
|
private static readonly string LOG_FILE = LogAPI.LOG_DIR + "\\log" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt"; |
|
|
|
// Token: 0x040001A9 RID: 425 |
|
private static readonly ILog m_log = LogManager.GetLogger(typeof(LogAPI)); |
|
} |
|
}
|
|
|