Browse Source

升级日志组件

懒得勤快 7 years ago
parent
commit
a1c1e08c67

+ 10 - 2
Masuit.Tools.Core/Extensions.cs

@@ -452,14 +452,22 @@ namespace Masuit.Tools
         /// </summary>
         /// </summary>
         /// <param name="source"></param>
         /// <param name="source"></param>
         /// <returns></returns>
         /// <returns></returns>
-        public static string ToJsonString(this object source) => JsonConvert.SerializeObject(source, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
+        public static string ToJsonString(this object source) => JsonConvert.SerializeObject(source, new JsonSerializerSettings()
+        {
+            ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
+            Formatting = Formatting.Indented
+        });
 
 
         /// <summary>
         /// <summary>
         /// 转换成json字符串
         /// 转换成json字符串
         /// </summary>
         /// </summary>
         /// <param name="source"></param>
         /// <param name="source"></param>
         /// <returns></returns>
         /// <returns></returns>
-        public static async Task<string> ToJsonStringAsync(this object source) => await Task.Run(() => JsonConvert.SerializeObject(source));
+        public static async Task<string> ToJsonStringAsync(this object source) => await Task.Run(() => JsonConvert.SerializeObject(source, new JsonSerializerSettings()
+        {
+            ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
+            Formatting = Formatting.Indented
+        }));
 
 
         #region UBB、HTML互转
         #region UBB、HTML互转
 
 

+ 19 - 0
Masuit.Tools.Core/Logging/LogInfo.cs

@@ -0,0 +1,19 @@
+using System;
+
+namespace Masuit.Tools.Core.Logging
+{
+    public class LogInfo
+    {
+        public DateTime Time { get; set; }
+        public int ThreadId { get; set; }
+        public LogLevel LogLevel { get; set; }
+        public string Source { get; set; }
+        public string Message { get; set; }
+    }
+
+    public class LogError : LogInfo
+    {
+        public Exception Exception { get; set; }
+        public string ExceptionType { get; set; }
+    }
+}

+ 7 - 0
Masuit.Tools.Core/Logging/LogLevel.cs

@@ -0,0 +1,7 @@
+namespace Masuit.Tools.Core.Logging
+{
+    public enum LogLevel
+    {
+        Info, Debug, Error, Fatal
+    }
+}

+ 230 - 19
Masuit.Tools.Core/Logging/LogManager.cs

@@ -16,7 +16,10 @@ namespace Masuit.Tools.Core.Logging
     {
     {
         static readonly ConcurrentQueue<Tuple<string, string>> LogQueue = new ConcurrentQueue<Tuple<string, string>>();
         static readonly ConcurrentQueue<Tuple<string, string>> LogQueue = new ConcurrentQueue<Tuple<string, string>>();
 
 
-        public static event Action<string> Event;
+        /// <summary>
+        /// 自定义事件
+        /// </summary>
+        public static event Action<LogInfo> Event;
         static LogManager()
         static LogManager()
         {
         {
             var writeTask = new Task(obj =>
             var writeTask = new Task(obj =>
@@ -28,7 +31,6 @@ namespace Masuit.Tools.Core.Logging
                     foreach (var logItem in LogQueue)
                     foreach (var logItem in LogQueue)
                     {
                     {
                         string logPath = logItem.Item1;
                         string logPath = logItem.Item1;
-                        Event?.Invoke(logItem.Item2);
                         string logMergeContent = String.Concat(logItem.Item2, Environment.NewLine, "----------------------------------------------------------------------------------------------------------------------", Environment.NewLine);
                         string logMergeContent = String.Concat(logItem.Item2, Environment.NewLine, "----------------------------------------------------------------------------------------------------------------------", Environment.NewLine);
                         string[] logArr = temp.FirstOrDefault(d => d[0].Equals(logPath));
                         string[] logArr = temp.FirstOrDefault(d => d[0].Equals(logPath));
                         if (logArr != null)
                         if (logArr != null)
@@ -58,116 +60,325 @@ namespace Masuit.Tools.Core.Logging
         /// </summary>
         /// </summary>
         public static string LogDirectory
         public static string LogDirectory
         {
         {
-            get => Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory).Any(s => s.Contains("Web.config")) ? AppDomain.CurrentDomain.BaseDirectory + @"App_Data\Logs\" : Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logs");
+            get => AppContext.BaseDirectory + "logs";
             set { }
             set { }
         }
         }
         /// <summary>
         /// <summary>
         /// 写入Info级别的日志
         /// 写入Info级别的日志
         /// </summary>
         /// </summary>
         /// <param name="info"></param>
         /// <param name="info"></param>
-        public static void Info(string info) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(info).ToUpper()}  {info}"));
+        public static void Info(string info)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(info).ToUpper()}  {info}"));
+            LogInfo log = new LogInfo()
+            {
+                LogLevel = LogLevel.Info,
+                Message = info,
+                Time = DateTime.Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入Info级别的日志
         /// 写入Info级别的日志
         /// </summary>
         /// </summary>
         /// <param name="source"></param>
         /// <param name="source"></param>
         /// <param name="info"></param>
         /// <param name="info"></param>
-        public static void Info(string source, string info) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(info).ToUpper()}   {source}  {info}"));
+        public static void Info(string source, string info)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(info).ToUpper()}   {source}  {info}"));
+            LogInfo log = new LogInfo()
+            {
+                LogLevel = LogLevel.Info,
+                Message = info,
+                Time = DateTime.Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入Info级别的日志
         /// 写入Info级别的日志
         /// </summary>
         /// </summary>
         /// <param name="source"></param>
         /// <param name="source"></param>
         /// <param name="info"></param>
         /// <param name="info"></param>
-        public static void Info(Type source, string info) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(info).ToUpper()}   {source.FullName}  {info}"));
+        public static void Info(Type source, string info)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(info).ToUpper()}   {source.FullName}  {info}"));
+            LogInfo log = new LogInfo()
+            {
+                LogLevel = LogLevel.Info,
+                Message = info,
+                Time = DateTime.Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source.FullName
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入debug级别日志
         /// 写入debug级别日志
         /// </summary>
         /// </summary>
         /// <param name="debug">异常对象</param>
         /// <param name="debug">异常对象</param>
-        public static void Debug(string debug) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(debug).ToUpper()}   {debug}"));
+        public static void Debug(string debug)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(debug).ToUpper()}   {debug}"));
+            LogInfo log = new LogInfo()
+            {
+                LogLevel = LogLevel.Debug,
+                Message = debug,
+                Time = DateTime.Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入debug级别日志
         /// 写入debug级别日志
         /// </summary>
         /// </summary>
         /// <param name="source">异常源的类型</param>
         /// <param name="source">异常源的类型</param>
         /// <param name="debug">异常对象</param>
         /// <param name="debug">异常对象</param>
-        public static void Debug(string source, string debug) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(debug).ToUpper()}   {source}  {debug}"));
+        public static void Debug(string source, string debug)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(debug).ToUpper()}   {source}  {debug}"));
+            LogInfo log = new LogInfo()
+            {
+                LogLevel = LogLevel.Debug,
+                Message = debug,
+                Time = DateTime.Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入debug级别日志
         /// 写入debug级别日志
         /// </summary>
         /// </summary>
         /// <param name="source">异常源的类型</param>
         /// <param name="source">异常源的类型</param>
         /// <param name="debug">异常对象</param>
         /// <param name="debug">异常对象</param>
-        public static void Debug(Type source, string debug) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(debug).ToUpper()}   {source.FullName}  {debug}"));
+        public static void Debug(Type source, string debug)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(debug).ToUpper()}   {source.FullName}  {debug}"));
+            LogInfo log = new LogInfo()
+            {
+                LogLevel = LogLevel.Debug,
+                Message = debug,
+                Time = DateTime.Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source.FullName
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入error级别日志
         /// 写入error级别日志
         /// </summary>
         /// </summary>
         /// <param name="error">异常对象</param>
         /// <param name="error">异常对象</param>
-        public static void Error(Exception error) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {error.Source}  {error.Message}{Environment.NewLine}{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {error.Source}  {error.StackTrace}"));
+        public static void Error(Exception error)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {error.Source}  {error.Message}{Environment.NewLine}{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {error.Source}  {error.StackTrace}"));
+            LogInfo log = new LogError()
+            {
+                LogLevel = LogLevel.Error,
+                Message = error.Message,
+                Time = DateTime.Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = error.Source,
+                Exception = error,
+                ExceptionType = error.GetType().Name
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入error级别日志
         /// 写入error级别日志
         /// </summary>
         /// </summary>
         /// <param name="source">异常源的类型</param>
         /// <param name="source">异常源的类型</param>
         /// <param name="error">异常对象</param>
         /// <param name="error">异常对象</param>
-        public static void Error(Type source, Exception error) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source.FullName}  {error.Message}{Environment.NewLine}{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source.FullName}  {error.StackTrace}"));
+        public static void Error(Type source, Exception error)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source.FullName}  {error.Message}{Environment.NewLine}{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source.FullName}  {error.StackTrace}"));
+            LogInfo log = new LogError()
+            {
+                LogLevel = LogLevel.Error,
+                Message = error.Message,
+                Time = DateTime.Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source.FullName,
+                Exception = error,
+                ExceptionType = error.GetType().Name
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入error级别日志
         /// 写入error级别日志
         /// </summary>
         /// </summary>
         /// <param name="source">异常源的类型</param>
         /// <param name="source">异常源的类型</param>
         /// <param name="error">异常信息</param>
         /// <param name="error">异常信息</param>
-        public static void Error(Type source, string error) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source.FullName}  {error}"));
+        public static void Error(Type source, string error)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source.FullName}  {error}"));
+            LogInfo log = new LogError()
+            {
+                LogLevel = LogLevel.Error,
+                Message = error,
+                Time = DateTime.Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source.FullName,
+                //Exception = error,
+                ExceptionType = error.GetType().Name
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入error级别日志
         /// 写入error级别日志
         /// </summary>
         /// </summary>
         /// <param name="source">异常源的类型</param>
         /// <param name="source">异常源的类型</param>
         /// <param name="error">异常对象</param>
         /// <param name="error">异常对象</param>
-        public static void Error(string source, Exception error) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source}  {error.Message}{Environment.NewLine}{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source}  {error.StackTrace}"));
+        public static void Error(string source, Exception error)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source}  {error.Message}{Environment.NewLine}{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source}  {error.StackTrace}"));
+            LogInfo log = new LogError()
+            {
+                LogLevel = LogLevel.Error,
+                Message = error.Message,
+                Time = DateTime.Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source,
+                Exception = error,
+                ExceptionType = error.GetType().Name
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入error级别日志
         /// 写入error级别日志
         /// </summary>
         /// </summary>
         /// <param name="source">异常源的类型</param>
         /// <param name="source">异常源的类型</param>
         /// <param name="error">异常信息</param>
         /// <param name="error">异常信息</param>
-        public static void Error(string source, string error) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source}  {error}"));
+        public static void Error(string source, string error)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source}  {error}"));
+            LogInfo log = new LogError()
+            {
+                LogLevel = LogLevel.Error,
+                Message = error,
+                Time = DateTime.Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source,
+                //Exception = error,
+                ExceptionType = error.GetType().Name
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入fatal级别日志
         /// 写入fatal级别日志
         /// </summary>
         /// </summary>
         /// <param name="fatal">异常对象</param>
         /// <param name="fatal">异常对象</param>
-        public static void Fatal(Exception fatal) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {fatal.Source}  {fatal.Message}{Environment.NewLine}{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {fatal.Source}  {fatal.StackTrace}"));
+        public static void Fatal(Exception fatal)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {fatal.Source}  {fatal.Message}{Environment.NewLine}{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {fatal.Source}  {fatal.StackTrace}"));
+            LogInfo log = new LogError()
+            {
+                LogLevel = LogLevel.Fatal,
+                Message = fatal.Message,
+                Time = DateTime.Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = fatal.Source,
+                Exception = fatal,
+                ExceptionType = fatal.GetType().Name
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入fatal级别日志
         /// 写入fatal级别日志
         /// </summary>
         /// </summary>
         /// <param name="source">异常源的类型</param>
         /// <param name="source">异常源的类型</param>
         /// <param name="fatal">异常对象</param>
         /// <param name="fatal">异常对象</param>
-        public static void Fatal(Type source, Exception fatal) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source.FullName}  {fatal.Message}{Environment.NewLine}{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source.FullName}  {fatal.StackTrace}"));
+        public static void Fatal(Type source, Exception fatal)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source.FullName}  {fatal.Message}{Environment.NewLine}{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source.FullName}  {fatal.StackTrace}"));
+            LogInfo log = new LogError()
+            {
+                LogLevel = LogLevel.Fatal,
+                Message = fatal.Message,
+                Time = DateTime.Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source.FullName,
+                Exception = fatal,
+                ExceptionType = fatal.GetType().Name
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入fatal级别日志
         /// 写入fatal级别日志
         /// </summary>
         /// </summary>
         /// <param name="source">异常源的类型</param>
         /// <param name="source">异常源的类型</param>
         /// <param name="fatal">异常对象</param>
         /// <param name="fatal">异常对象</param>
-        public static void Fatal(Type source, string fatal) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source.FullName}  {fatal}"));
+        public static void Fatal(Type source, string fatal)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source.FullName}  {fatal}"));
+            LogInfo log = new LogError()
+            {
+                LogLevel = LogLevel.Fatal,
+                Message = fatal,
+                Time = DateTime.Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source.FullName,
+                //Exception = fatal,
+                ExceptionType = fatal.GetType().Name
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入fatal级别日志
         /// 写入fatal级别日志
         /// </summary>
         /// </summary>
         /// <param name="source">异常源的类型</param>
         /// <param name="source">异常源的类型</param>
         /// <param name="fatal">异常对象</param>
         /// <param name="fatal">异常对象</param>
-        public static void Fatal(string source, Exception fatal) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source}  {fatal.Message}{Environment.NewLine}{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source}  {fatal.StackTrace}"));
+        public static void Fatal(string source, Exception fatal)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source}  {fatal.Message}{Environment.NewLine}{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source}  {fatal.StackTrace}"));
+            LogInfo log = new LogError()
+            {
+                LogLevel = LogLevel.Fatal,
+                Message = fatal.Message,
+                Time = DateTime.Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source,
+                Exception = fatal,
+                ExceptionType = fatal.GetType().Name
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入fatal级别日志
         /// 写入fatal级别日志
         /// </summary>
         /// </summary>
         /// <param name="source">异常源的类型</param>
         /// <param name="source">异常源的类型</param>
         /// <param name="fatal">异常对象</param>
         /// <param name="fatal">异常对象</param>
-        public static void Fatal(string source, string fatal) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source}  {fatal}"));
+        public static void Fatal(string source, string fatal)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{DateTime.Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source}  {fatal}"));
+            LogInfo log = new LogError()
+            {
+                LogLevel = LogLevel.Fatal,
+                Message = fatal,
+                Time = DateTime.Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source,
+                ExceptionType = fatal.GetType().Name
+            };
+            Event?.Invoke(log);
+        }
 
 
         private static string GetLogPath()
         private static string GetLogPath()
         {
         {

+ 8 - 0
Masuit.Tools.Core/Logging/WebLogInfo.cs

@@ -0,0 +1,8 @@
+namespace Masuit.Tools.Core.Logging
+{
+    public class WebLogInfo : LogError
+    {
+        public string RequestUrl { get; set; }
+        public string UserAgent { get; set; }
+    }
+}

+ 19 - 0
Masuit.Tools/Logging/LogInfo.cs

@@ -0,0 +1,19 @@
+using System;
+
+namespace Masuit.Tools.Logging
+{
+    public class LogInfo
+    {
+        public DateTime Time { get; set; }
+        public int ThreadId { get; set; }
+        public LogLevel LogLevel { get; set; }
+        public string Source { get; set; }
+        public string Message { get; set; }
+    }
+
+    public class LogError : LogInfo
+    {
+        public Exception Exception { get; set; }
+        public string ExceptionType { get; set; }
+    }
+}

+ 7 - 0
Masuit.Tools/Logging/LogLevel.cs

@@ -0,0 +1,7 @@
+namespace Masuit.Tools.Logging
+{
+    public enum LogLevel
+    {
+        Info, Debug, Error, Fatal
+    }
+}

+ 226 - 18
Masuit.Tools/Logging/LogManager.cs

@@ -20,7 +20,7 @@ namespace Masuit.Tools.Logging
         /// <summary>
         /// <summary>
         /// 自定义事件
         /// 自定义事件
         /// </summary>
         /// </summary>
-        public static event Action<string> Event;
+        public static event Action<LogInfo> Event;
         static LogManager()
         static LogManager()
         {
         {
             var writeTask = new Task(obj =>
             var writeTask = new Task(obj =>
@@ -32,7 +32,6 @@ namespace Masuit.Tools.Logging
                     foreach (var logItem in LogQueue)
                     foreach (var logItem in LogQueue)
                     {
                     {
                         string logPath = logItem.Item1;
                         string logPath = logItem.Item1;
-                        Event?.Invoke(logItem.Item2);
                         string logMergeContent = String.Concat(logItem.Item2, Environment.NewLine, "----------------------------------------------------------------------------------------------------------------------", Environment.NewLine);
                         string logMergeContent = String.Concat(logItem.Item2, Environment.NewLine, "----------------------------------------------------------------------------------------------------------------------", Environment.NewLine);
                         string[] logArr = temp.FirstOrDefault(d => d[0].Equals(logPath));
                         string[] logArr = temp.FirstOrDefault(d => d[0].Equals(logPath));
                         if (logArr != null)
                         if (logArr != null)
@@ -69,109 +68,318 @@ namespace Masuit.Tools.Logging
         /// 写入Info级别的日志
         /// 写入Info级别的日志
         /// </summary>
         /// </summary>
         /// <param name="info"></param>
         /// <param name="info"></param>
-        public static void Info(string info) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(info).ToUpper()}  {info}"));
+        public static void Info(string info)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(info).ToUpper()}  {info}"));
+            LogInfo log = new LogInfo()
+            {
+                LogLevel = LogLevel.Info,
+                Message = info,
+                Time = Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入Info级别的日志
         /// 写入Info级别的日志
         /// </summary>
         /// </summary>
         /// <param name="source"></param>
         /// <param name="source"></param>
         /// <param name="info"></param>
         /// <param name="info"></param>
-        public static void Info(string source, string info) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(info).ToUpper()}   {source}  {info}"));
+        public static void Info(string source, string info)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(info).ToUpper()}   {source}  {info}"));
+            LogInfo log = new LogInfo()
+            {
+                LogLevel = LogLevel.Info,
+                Message = info,
+                Time = Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入Info级别的日志
         /// 写入Info级别的日志
         /// </summary>
         /// </summary>
         /// <param name="source"></param>
         /// <param name="source"></param>
         /// <param name="info"></param>
         /// <param name="info"></param>
-        public static void Info(Type source, string info) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(info).ToUpper()}   {source.FullName}  {info}"));
+        public static void Info(Type source, string info)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(info).ToUpper()}   {source.FullName}  {info}"));
+            LogInfo log = new LogInfo()
+            {
+                LogLevel = LogLevel.Info,
+                Message = info,
+                Time = Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source.FullName
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入debug级别日志
         /// 写入debug级别日志
         /// </summary>
         /// </summary>
         /// <param name="debug">异常对象</param>
         /// <param name="debug">异常对象</param>
-        public static void Debug(string debug) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(debug).ToUpper()}   {debug}"));
+        public static void Debug(string debug)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(debug).ToUpper()}   {debug}"));
+            LogInfo log = new LogInfo()
+            {
+                LogLevel = LogLevel.Debug,
+                Message = debug,
+                Time = Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入debug级别日志
         /// 写入debug级别日志
         /// </summary>
         /// </summary>
         /// <param name="source">异常源的类型</param>
         /// <param name="source">异常源的类型</param>
         /// <param name="debug">异常对象</param>
         /// <param name="debug">异常对象</param>
-        public static void Debug(string source, string debug) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(debug).ToUpper()}   {source}  {debug}"));
+        public static void Debug(string source, string debug)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(debug).ToUpper()}   {source}  {debug}"));
+            LogInfo log = new LogInfo()
+            {
+                LogLevel = LogLevel.Debug,
+                Message = debug,
+                Time = Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入debug级别日志
         /// 写入debug级别日志
         /// </summary>
         /// </summary>
         /// <param name="source">异常源的类型</param>
         /// <param name="source">异常源的类型</param>
         /// <param name="debug">异常对象</param>
         /// <param name="debug">异常对象</param>
-        public static void Debug(Type source, string debug) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(debug).ToUpper()}   {source.FullName}  {debug}"));
+        public static void Debug(Type source, string debug)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(debug).ToUpper()}   {source.FullName}  {debug}"));
+            LogInfo log = new LogInfo()
+            {
+                LogLevel = LogLevel.Debug,
+                Message = debug,
+                Time = Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source.FullName
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入error级别日志
         /// 写入error级别日志
         /// </summary>
         /// </summary>
         /// <param name="error">异常对象</param>
         /// <param name="error">异常对象</param>
-        public static void Error(Exception error) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {error.Source}  {error.Message}{Environment.NewLine}{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {error.Source}  {error.StackTrace}"));
+        public static void Error(Exception error)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {error.Source}  {error.Message}{Environment.NewLine}{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {error.Source}  {error.StackTrace}"));
+            LogInfo log = new LogError()
+            {
+                LogLevel = LogLevel.Error,
+                Message = error.Message,
+                Time = Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = error.Source,
+                Exception = error,
+                ExceptionType = error.GetType().Name
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入error级别日志
         /// 写入error级别日志
         /// </summary>
         /// </summary>
         /// <param name="source">异常源的类型</param>
         /// <param name="source">异常源的类型</param>
         /// <param name="error">异常对象</param>
         /// <param name="error">异常对象</param>
-        public static void Error(Type source, Exception error) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source.FullName}  {error.Message}{Environment.NewLine}{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source.FullName}  {error.StackTrace}"));
+        public static void Error(Type source, Exception error)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source.FullName}  {error.Message}{Environment.NewLine}{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source.FullName}  {error.StackTrace}"));
+            LogInfo log = new LogError()
+            {
+                LogLevel = LogLevel.Error,
+                Message = error.Message,
+                Time = Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source.FullName,
+                Exception = error,
+                ExceptionType = error.GetType().Name
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入error级别日志
         /// 写入error级别日志
         /// </summary>
         /// </summary>
         /// <param name="source">异常源的类型</param>
         /// <param name="source">异常源的类型</param>
         /// <param name="error">异常信息</param>
         /// <param name="error">异常信息</param>
-        public static void Error(Type source, string error) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source.FullName}  {error}"));
+        public static void Error(Type source, string error)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source.FullName}  {error}"));
+            LogInfo log = new LogError()
+            {
+                LogLevel = LogLevel.Error,
+                Message = error,
+                Time = Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source.FullName,
+                //Exception = error,
+                ExceptionType = error.GetType().Name
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入error级别日志
         /// 写入error级别日志
         /// </summary>
         /// </summary>
         /// <param name="source">异常源的类型</param>
         /// <param name="source">异常源的类型</param>
         /// <param name="error">异常对象</param>
         /// <param name="error">异常对象</param>
-        public static void Error(string source, Exception error) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source}  {error.Message}{Environment.NewLine}{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source}  {error.StackTrace}"));
+        public static void Error(string source, Exception error)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source}  {error.Message}{Environment.NewLine}{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source}  {error.StackTrace}"));
+            LogInfo log = new LogError()
+            {
+                LogLevel = LogLevel.Error,
+                Message = error.Message,
+                Time = Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source,
+                Exception = error,
+                ExceptionType = error.GetType().Name
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入error级别日志
         /// 写入error级别日志
         /// </summary>
         /// </summary>
         /// <param name="source">异常源的类型</param>
         /// <param name="source">异常源的类型</param>
         /// <param name="error">异常信息</param>
         /// <param name="error">异常信息</param>
-        public static void Error(string source, string error) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source}  {error}"));
+        public static void Error(string source, string error)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(error).ToUpper()}   {source}  {error}"));
+            LogInfo log = new LogError()
+            {
+                LogLevel = LogLevel.Error,
+                Message = error,
+                Time = Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source,
+                //Exception = error,
+                ExceptionType = error.GetType().Name
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入fatal级别日志
         /// 写入fatal级别日志
         /// </summary>
         /// </summary>
         /// <param name="fatal">异常对象</param>
         /// <param name="fatal">异常对象</param>
-        public static void Fatal(Exception fatal) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {fatal.Source}  {fatal.Message}{Environment.NewLine}{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {fatal.Source}  {fatal.StackTrace}"));
+        public static void Fatal(Exception fatal)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {fatal.Source}  {fatal.Message}{Environment.NewLine}{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {fatal.Source}  {fatal.StackTrace}"));
+            LogInfo log = new LogError()
+            {
+                LogLevel = LogLevel.Fatal,
+                Message = fatal.Message,
+                Time = Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = fatal.Source,
+                Exception = fatal,
+                ExceptionType = fatal.GetType().Name
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入fatal级别日志
         /// 写入fatal级别日志
         /// </summary>
         /// </summary>
         /// <param name="source">异常源的类型</param>
         /// <param name="source">异常源的类型</param>
         /// <param name="fatal">异常对象</param>
         /// <param name="fatal">异常对象</param>
-        public static void Fatal(Type source, Exception fatal) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source.FullName}  {fatal.Message}{Environment.NewLine}{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source.FullName}  {fatal.StackTrace}"));
+        public static void Fatal(Type source, Exception fatal)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source.FullName}  {fatal.Message}{Environment.NewLine}{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source.FullName}  {fatal.StackTrace}"));
+            LogInfo log = new LogError()
+            {
+                LogLevel = LogLevel.Fatal,
+                Message = fatal.Message,
+                Time = Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source.FullName,
+                Exception = fatal,
+                ExceptionType = fatal.GetType().Name
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入fatal级别日志
         /// 写入fatal级别日志
         /// </summary>
         /// </summary>
         /// <param name="source">异常源的类型</param>
         /// <param name="source">异常源的类型</param>
         /// <param name="fatal">异常对象</param>
         /// <param name="fatal">异常对象</param>
-        public static void Fatal(Type source, string fatal) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source.FullName}  {fatal}"));
+        public static void Fatal(Type source, string fatal)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source.FullName}  {fatal}"));
+            LogInfo log = new LogError()
+            {
+                LogLevel = LogLevel.Fatal,
+                Message = fatal,
+                Time = Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source.FullName,
+                //Exception = fatal,
+                ExceptionType = fatal.GetType().Name
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入fatal级别日志
         /// 写入fatal级别日志
         /// </summary>
         /// </summary>
         /// <param name="source">异常源的类型</param>
         /// <param name="source">异常源的类型</param>
         /// <param name="fatal">异常对象</param>
         /// <param name="fatal">异常对象</param>
-        public static void Fatal(string source, Exception fatal) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source}  {fatal.Message}{Environment.NewLine}{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source}  {fatal.StackTrace}"));
+        public static void Fatal(string source, Exception fatal)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source}  {fatal.Message}{Environment.NewLine}{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source}  {fatal.StackTrace}"));
+            LogInfo log = new LogError()
+            {
+                LogLevel = LogLevel.Fatal,
+                Message = fatal.Message,
+                Time = Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source,
+                Exception = fatal,
+                ExceptionType = fatal.GetType().Name
+            };
+            Event?.Invoke(log);
+        }
 
 
         /// <summary>
         /// <summary>
         /// 写入fatal级别日志
         /// 写入fatal级别日志
         /// </summary>
         /// </summary>
         /// <param name="source">异常源的类型</param>
         /// <param name="source">异常源的类型</param>
         /// <param name="fatal">异常对象</param>
         /// <param name="fatal">异常对象</param>
-        public static void Fatal(string source, string fatal) => LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source}  {fatal}"));
+        public static void Fatal(string source, string fatal)
+        {
+            LogQueue.Enqueue(new Tuple<string, string>(GetLogPath(), $"{Now}   [{Thread.CurrentThread.ManagedThreadId}]   {nameof(fatal).ToUpper()}   {source}  {fatal}"));
+            LogInfo log = new LogError()
+            {
+                LogLevel = LogLevel.Fatal,
+                Message = fatal,
+                Time = Now,
+                ThreadId = Thread.CurrentThread.ManagedThreadId,
+                Source = source,
+                ExceptionType = fatal.GetType().Name
+            };
+            Event?.Invoke(log);
+        }
 
 
         private static string GetLogPath()
         private static string GetLogPath()
         {
         {

+ 8 - 0
Masuit.Tools/Logging/WebLogInfo.cs

@@ -0,0 +1,8 @@
+namespace Masuit.Tools.Logging
+{
+    public class WebLogInfo : LogError
+    {
+        public string RequestUrl { get; set; }
+        public string UserAgent { get; set; }
+    }
+}

+ 3 - 0
Masuit.Tools/Masuit.Tools.csproj

@@ -94,7 +94,10 @@
     <Compile Include="Html\HtmlTools.cs" />
     <Compile Include="Html\HtmlTools.cs" />
     <Compile Include="Linq\LinqExtension.cs" />
     <Compile Include="Linq\LinqExtension.cs" />
     <Compile Include="Linq\ParameterReplacer.cs" />
     <Compile Include="Linq\ParameterReplacer.cs" />
+    <Compile Include="Logging\LogInfo.cs" />
+    <Compile Include="Logging\LogLevel.cs" />
     <Compile Include="Logging\LogManager.cs" />
     <Compile Include="Logging\LogManager.cs" />
+    <Compile Include="Logging\WebLogInfo.cs" />
     <Compile Include="Models\BaiduIP.cs" />
     <Compile Include="Models\BaiduIP.cs" />
     <Compile Include="Models\IspInfo.cs" />
     <Compile Include="Models\IspInfo.cs" />
     <Compile Include="Models\PhysicsAddress.cs" />
     <Compile Include="Models\PhysicsAddress.cs" />

+ 8 - 5
NetCoreTest/Program.cs

@@ -1,8 +1,6 @@
 using System;
 using System;
-using System.Collections.Generic;
-using Masuit.Tools.NoSQL.MongoDBClient;
-using MongoDB.Bson;
-using MongoDB.Driver;
+using Masuit.Tools;
+using Masuit.Tools.Core.Logging;
 
 
 namespace NetCoreTest
 namespace NetCoreTest
 {
 {
@@ -10,7 +8,12 @@ namespace NetCoreTest
     {
     {
         static void Main(string[] args)
         static void Main(string[] args)
         {
         {
-            Console.WriteLine("ok");
+            Console.WriteLine(AppContext.BaseDirectory);
+            LogManager.Event += info =>
+              {
+                  Console.WriteLine(info.ToJsonString());
+              };
+            LogManager.Error(new Exception("测试异常"));
         }
         }
     }
     }
 }
 }