diff --git a/ToolLib.Log/LogForm/DetailMesForm.Designer.cs b/ToolLib.Log/LogForm/DetailMesForm.Designer.cs
new file mode 100644
index 0000000..43b401d
--- /dev/null
+++ b/ToolLib.Log/LogForm/DetailMesForm.Designer.cs
@@ -0,0 +1,137 @@
+namespace LogForm
+{
+ partial class DetailMesForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.btnClose = new System.Windows.Forms.Button();
+ this.Rtb_DetailMes = new System.Windows.Forms.RichTextBox();
+ this.lb_Level = new System.Windows.Forms.Label();
+ this.lb_Time = new System.Windows.Forms.Label();
+ this.lb_Detail = new System.Windows.Forms.Label();
+ this.label3 = new System.Windows.Forms.Label();
+ this.label1 = new System.Windows.Forms.Label();
+ this.SuspendLayout();
+ //
+ // btnClose
+ //
+ this.btnClose.Location = new System.Drawing.Point(427, 334);
+ this.btnClose.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.btnClose.Name = "btnClose";
+ this.btnClose.Size = new System.Drawing.Size(99, 33);
+ this.btnClose.TabIndex = 9;
+ this.btnClose.Text = "关闭";
+ this.btnClose.UseVisualStyleBackColor = true;
+ this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
+ //
+ // Rtb_DetailMes
+ //
+ this.Rtb_DetailMes.Location = new System.Drawing.Point(29, 140);
+ this.Rtb_DetailMes.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.Rtb_DetailMes.Name = "Rtb_DetailMes";
+ this.Rtb_DetailMes.Size = new System.Drawing.Size(503, 182);
+ this.Rtb_DetailMes.TabIndex = 8;
+ this.Rtb_DetailMes.Text = "";
+ //
+ // lb_Level
+ //
+ this.lb_Level.AutoSize = true;
+ this.lb_Level.Location = new System.Drawing.Point(110, 57);
+ this.lb_Level.Name = "lb_Level";
+ this.lb_Level.Size = new System.Drawing.Size(0, 17);
+ this.lb_Level.TabIndex = 3;
+ //
+ // lb_Time
+ //
+ this.lb_Time.AutoSize = true;
+ this.lb_Time.Location = new System.Drawing.Point(110, 16);
+ this.lb_Time.Name = "lb_Time";
+ this.lb_Time.Size = new System.Drawing.Size(0, 17);
+ this.lb_Time.TabIndex = 4;
+ //
+ // lb_Detail
+ //
+ this.lb_Detail.AutoSize = true;
+ this.lb_Detail.Location = new System.Drawing.Point(25, 100);
+ this.lb_Detail.Name = "lb_Detail";
+ this.lb_Detail.Size = new System.Drawing.Size(79, 17);
+ this.lb_Detail.TabIndex = 5;
+ this.lb_Detail.Text = "Log详细信息";
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(25, 57);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(67, 17);
+ this.label3.TabIndex = 6;
+ this.label3.Text = "Log级别:";
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(25, 16);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(44, 17);
+ this.label1.TabIndex = 7;
+ this.label1.Text = "时间:";
+ //
+ // DetailMesForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 17F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.BackColor = System.Drawing.Color.White;
+ this.ClientSize = new System.Drawing.Size(544, 381);
+ this.ControlBox = false;
+ this.Controls.Add(this.btnClose);
+ this.Controls.Add(this.Rtb_DetailMes);
+ this.Controls.Add(this.lb_Level);
+ this.Controls.Add(this.lb_Time);
+ this.Controls.Add(this.lb_Detail);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.label1);
+ this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+ this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.Name = "DetailMesForm";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Load += new System.EventHandler(this.DetailMesForm_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button btnClose;
+ private System.Windows.Forms.RichTextBox Rtb_DetailMes;
+ private System.Windows.Forms.Label lb_Level;
+ private System.Windows.Forms.Label lb_Time;
+ private System.Windows.Forms.Label lb_Detail;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Label label1;
+ }
+}
\ No newline at end of file
diff --git a/ToolLib.Log/LogForm/DetailMesForm.cs b/ToolLib.Log/LogForm/DetailMesForm.cs
new file mode 100644
index 0000000..76c108b
--- /dev/null
+++ b/ToolLib.Log/LogForm/DetailMesForm.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace LogForm
+{
+ public partial class DetailMesForm : Form
+ {
+ private string detailMsg = string.Empty;
+ public DetailMesForm(string detailMsg)
+ {
+ InitializeComponent();
+ this.detailMsg = detailMsg;
+ }
+
+ private void btnClose_Click(object sender, EventArgs e)
+ {
+ this.Close();
+ }
+
+ private void DetailMesForm_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ string time = detailMsg.Split('>')[0];
+ string level = detailMsg.Split(',')[0].Split('>')[1];
+ lb_Time.Text = time;
+ lb_Level.Text = level;
+ Rtb_DetailMes.Text = detailMsg;
+ }
+ catch (Exception)
+ {
+ Rtb_DetailMes.Text = detailMsg;
+ }
+
+ }
+ }
+}
diff --git a/ToolLib.Log/LogForm/DetailMesForm.resx b/ToolLib.Log/LogForm/DetailMesForm.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/ToolLib.Log/LogForm/DetailMesForm.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/ToolLib.Log/LogForm/LogForm.csproj b/ToolLib.Log/LogForm/LogForm.csproj
new file mode 100644
index 0000000..67ab386
--- /dev/null
+++ b/ToolLib.Log/LogForm/LogForm.csproj
@@ -0,0 +1,86 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {6B38D68F-E77B-4761-BDE5-A261EA8925DD}
+ Library
+ Properties
+ LogForm
+ LogForm
+ v4.5.2
+ 512
+
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ DetailMesForm.cs
+
+
+
+ UserControl
+
+
+ UserLogger.cs
+
+
+
+
+ DetailMesForm.cs
+
+
+ UserLogger.cs
+
+
+
+
+ {bec2389f-b8b4-4e8a-8c71-189cde14e962}
+ EnumList
+
+
+ {d4e052b9-e541-4b67-a1f9-273073ef1d4b}
+ Logger
+
+
+
+
+
\ No newline at end of file
diff --git a/ToolLib.Log/LogForm/Properties/AssemblyInfo.cs b/ToolLib.Log/LogForm/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..6618900
--- /dev/null
+++ b/ToolLib.Log/LogForm/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("LogForm")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("LogForm")]
+[assembly: AssemblyCopyright("Copyright © 2020")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+//将 ComVisible 设置为 false 将使此程序集中的类型
+//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("6b38d68f-e77b-4761-bde5-a261ea8925dd")]
+
+// 程序集的版本信息由下列四个值组成:
+//
+// 主版本
+// 次版本
+// 生成号
+// 修订号
+//
+//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
+// 方法是按如下所示使用“*”: :
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/ToolLib.Log/LogForm/UserLogger.Designer.cs b/ToolLib.Log/LogForm/UserLogger.Designer.cs
new file mode 100644
index 0000000..45bb0b7
--- /dev/null
+++ b/ToolLib.Log/LogForm/UserLogger.Designer.cs
@@ -0,0 +1,91 @@
+namespace LogForm
+{
+ partial class UserLogger
+ {
+ ///
+ /// 必需的设计器变量。
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// 清理所有正在使用的资源。
+ ///
+ /// 如果应释放托管资源,为 true;否则为 false。
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region 组件设计器生成的代码
+
+ ///
+ /// 设计器支持所需的方法 - 不要修改
+ /// 使用代码编辑器修改此方法的内容。
+ ///
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.listBox1 = new System.Windows.Forms.ListBox();
+ this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
+ this.ClearLog = new System.Windows.Forms.ToolStripMenuItem();
+ this.contextMenuStrip1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // listBox1
+ //
+ this.listBox1.BackColor = System.Drawing.SystemColors.Info;
+ this.listBox1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.listBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
+ this.listBox1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+ this.listBox1.FormattingEnabled = true;
+ this.listBox1.HorizontalScrollbar = true;
+ this.listBox1.ItemHeight = 18;
+ this.listBox1.Location = new System.Drawing.Point(0, 0);
+ this.listBox1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.listBox1.Name = "listBox1";
+ this.listBox1.Size = new System.Drawing.Size(365, 266);
+ this.listBox1.TabIndex = 0;
+ this.listBox1.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.listBox1_DrawItem);
+ this.listBox1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listBox1_MouseDoubleClick);
+ //
+ // contextMenuStrip1
+ //
+ this.contextMenuStrip1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+ this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.ClearLog});
+ this.contextMenuStrip1.Name = "contextMenuStrip1";
+ this.contextMenuStrip1.Size = new System.Drawing.Size(107, 28);
+ //
+ // ClearLog
+ //
+ this.ClearLog.Name = "ClearLog";
+ this.ClearLog.Size = new System.Drawing.Size(106, 24);
+ this.ClearLog.Text = "清空";
+ this.ClearLog.Click += new System.EventHandler(this.ClearLog_Click);
+ //
+ // UserLogger
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.AutoSize = true;
+ this.Controls.Add(this.listBox1);
+ this.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+ this.Name = "UserLogger";
+ this.Size = new System.Drawing.Size(365, 266);
+ this.Load += new System.EventHandler(this.UserLogger_Load);
+ this.contextMenuStrip1.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ public System.Windows.Forms.ListBox listBox1;
+ private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
+ private System.Windows.Forms.ToolStripMenuItem ClearLog;
+ }
+}
diff --git a/ToolLib.Log/LogForm/UserLogger.cs b/ToolLib.Log/LogForm/UserLogger.cs
new file mode 100644
index 0000000..a75f1e9
--- /dev/null
+++ b/ToolLib.Log/LogForm/UserLogger.cs
@@ -0,0 +1,160 @@
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using Logger;
+using System.Threading.Tasks;
+using System.IO;
+using System.Collections.Generic;
+
+namespace LogForm
+{
+ public partial class UserLogger : UserControl
+ {
+ bool logFocus = true;
+ string logDictory = @"C:\MyCCDSystem\Log\";
+ public UserLogger()
+ {
+ InitializeComponent();
+ }
+ ~UserLogger()
+ {
+ logFocus = false;
+ }
+
+ private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
+ {
+ if (e.Index < 0)
+ { return; }
+ else
+ {
+ e.DrawBackground();
+ Brush mybsh = Brushes.Black;
+ // 判断是什么类型的标签,在调用时必须信息前边标注信息的类别,分为Info,Warning,Error
+ try
+ {
+ MsgLevel msgLevel = (MsgLevel)Enum.Parse(typeof(MsgLevel), listBox1.Items[e.Index].ToString().Split('>')[1].Trim().Split(',')[0]);
+ switch (msgLevel)
+ {
+ case MsgLevel.Info:
+ mybsh = Brushes.Green;
+ break;
+ case MsgLevel.Debug:
+ mybsh = Brushes.Green;
+ break;
+ case MsgLevel.Warn:
+ mybsh = Brushes.Purple;
+ break;
+ case MsgLevel.Exception:
+ case MsgLevel.Fatal:
+ mybsh = Brushes.Red;
+ break;
+ default:
+ mybsh = Brushes.Black;
+ break;
+ }
+ }
+ catch (Exception)
+ {
+ mybsh = Brushes.Green;
+ }
+ e.DrawFocusRectangle();
+ e.Graphics.DrawString(listBox1.Items[e.Index].ToString(), e.Font, mybsh, e.Bounds, StringFormat.GenericDefault);
+ }
+ }
+
+
+ public void AddLog(MsgLevel msgLog, string logInfo)
+ {
+ try
+ {
+ this.Invoke((MethodInvoker)delegate
+ {
+ string recordMsg = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} -> {msgLog.ToString()}, {logInfo}";
+ listBox1.Items.Add(recordMsg);
+ WriteLog(recordMsg);
+ listBox1.SelectedIndex = listBox1.Items.Count - 1;
+ if (listBox1.Items.Count > 1000)
+ {
+ listBox1.Items.Clear();
+ }
+ Application.DoEvents();
+ });
+ }
+ catch(Exception)
+ {
+
+ }
+ }
+ public void AddLog(MsgLevel msgLog, string logInfo, Exception ex)
+ {
+ try
+ {
+ this.Invoke((MethodInvoker)delegate
+ {
+ listBox1.Items.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " -> " + msgLog.ToString() + "," + logInfo + ex);
+ listBox1.SelectedIndex = listBox1.Items.Count - 1;
+ WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " -> " + msgLog.ToString() + "," + logInfo + ex);
+ if(listBox1.Items.Count >1000)
+ {
+ listBox1.Items.Clear();
+ }
+ Application.DoEvents();
+ });
+ }
+ catch (Exception)
+ {
+
+ }
+ }
+ public void WriteLog(string msg)
+ {
+ string time = DateTime.Now.ToString("HH:mm:ss.fff");
+ if (!Directory.Exists(logDictory))
+ {
+ Directory.CreateDirectory(logDictory);
+ }
+ string runningLogFileName = logDictory + DateTime.Now.ToString("yyyyMMdd") + ".log";
+ StreamWriter mySW = new StreamWriter(runningLogFileName, true);
+ mySW.WriteLine(msg);
+ mySW.Close();
+ }
+ private void UserLogger_Load(object sender, EventArgs e)
+ {
+ Task startLogFocus = new Task(() =>
+ {
+ while (logFocus)
+ {
+ if (LoggerClass.logQueue.Count > 0)
+ {
+ LogInfo log = LoggerClass.logQueue.Dequeue();
+ if (log.ex != null)
+ {
+ AddLog(log.logLevel, log.message, log.ex);
+ }
+ else
+ {
+ AddLog(log.logLevel, log.message);
+ }
+
+ }
+ }
+ });
+ startLogFocus.Start();
+ }
+
+ private void ClearLog_Click(object sender, EventArgs e)
+ {
+ this.listBox1.Items.Clear();
+ }
+
+ private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
+ {
+ if(listBox1.SelectedIndex != -1)
+ {
+ string detalText = listBox1.SelectedItem.ToString();
+ DetailMesForm myForm = new DetailMesForm(detalText);
+ myForm.Show();
+ }
+ }
+ }
+}
diff --git a/ToolLib.Log/LogForm/UserLogger.resx b/ToolLib.Log/LogForm/UserLogger.resx
new file mode 100644
index 0000000..ad53752
--- /dev/null
+++ b/ToolLib.Log/LogForm/UserLogger.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/ToolLib.Log/Logger/Logger.csproj b/ToolLib.Log/Logger/Logger.csproj
new file mode 100644
index 0000000..f560130
--- /dev/null
+++ b/ToolLib.Log/Logger/Logger.csproj
@@ -0,0 +1,71 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {D4E052B9-E541-4B67-A1F9-273073EF1D4B}
+ Library
+ Properties
+ Logger
+ Logger
+ v4.5.2
+ 512
+
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ False
+ F:\VSCode\LearnTest\Reflection\bin\Debug\log4net.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+
+
+ {bec2389f-b8b4-4e8a-8c71-189cde14e962}
+ EnumList
+
+
+
+
+
\ No newline at end of file
diff --git a/ToolLib.Log/Logger/LoggerClass.cs b/ToolLib.Log/Logger/LoggerClass.cs
new file mode 100644
index 0000000..628ca68
--- /dev/null
+++ b/ToolLib.Log/Logger/LoggerClass.cs
@@ -0,0 +1,97 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using log4net;
+using System.Windows.Forms;
+
+namespace Logger
+{
+ public class LoggerClass
+ {
+ public static readonly ILog loginfo = LogManager.GetLogger("loginfo");
+ public static readonly ILog logerror = LogManager.GetLogger("logerror");
+ ///
+ /// Log队列
+ ///
+ public static Queue logQueue { get; set; } = new Queue() { };
+ public static void WriteLog(string info, bool ShowMsgBox = false)
+ {
+ if (loginfo.IsInfoEnabled)
+ {
+ loginfo.Info(info);
+ }
+ logQueue.Enqueue(new LogInfo{ message = info, ex = null, logLevel = MsgLevel.Info});
+ if(ShowMsgBox)
+ {
+ MessageBox.Show(info);
+ }
+ }
+ public static void WriteLog(string info, MsgLevel msgLevel, bool ShowMsgBox = false)
+ {
+ if (loginfo.IsInfoEnabled)
+ {
+ loginfo.Info(info);
+ }
+ logQueue.Enqueue(new LogInfo { message = info,ex = null, logLevel = msgLevel });
+ if (ShowMsgBox)
+ {
+ MessageBox.Show(info);
+ }
+ }
+ public static void WriteLog(string info, MsgLevel msgLevel, Exception ex, bool ShowMsgBox = false)
+ {
+ if (logerror.IsErrorEnabled)
+ {
+ logerror.Error(info, ex);
+ }
+ logQueue.Enqueue(new LogInfo { message = info, ex = ex, logLevel = msgLevel });
+ if (ShowMsgBox)
+ {
+ MessageBox.Show(info);
+ }
+ }
+ public static void WriteLog(string info, Exception ex, bool ShowMsgBox = false)
+ {
+ if (logerror.IsErrorEnabled)
+ {
+ logerror.Error(info, ex);
+ }
+ logQueue.Enqueue(new LogInfo { message = info, ex = ex, logLevel = MsgLevel.Exception });
+ if (ShowMsgBox)
+ {
+ MessageBox.Show(info);
+ }
+ }
+ }
+ public class LogInfo
+ {
+ public string message { get; set; }
+ public MsgLevel logLevel { get; set; }
+ public Exception ex { get; set; }
+ }
+ public enum MsgLevel
+ {
+ ///
+ /// 0.调试信息输出
+ ///
+ Debug = 0,
+ ///
+ /// 1.业务信息记录
+ ///
+ Info = 1,
+ ///
+ /// 2.警告提醒(捕获的业务异常)
+ ///
+ Warn = 2,
+ ///
+ /// 3.发生了异常(捕获的系统异常)
+ ///
+ Exception = 3,
+ ///
+ /// 4.发生致命异常(未被捕获的异常|捕获的业务逻辑异常)
+ ///
+ Fatal = 4
+ }
+}
diff --git a/ToolLib.Log/Logger/Properties/AssemblyInfo.cs b/ToolLib.Log/Logger/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..07b7e71
--- /dev/null
+++ b/ToolLib.Log/Logger/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("Logger")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Logger")]
+[assembly: AssemblyCopyright("Copyright © 2020")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", ConfigFileExtension = "config", Watch = true)]
+//将 ComVisible 设置为 false 将使此程序集中的类型
+//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("d4e052b9-e541-4b67-a1f9-273073ef1d4b")]
+
+// 程序集的版本信息由下列四个值组成:
+//
+// 主版本
+// 次版本
+// 生成号
+// 修订号
+//
+//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
+// 方法是按如下所示使用“*”: :
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+//[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", ConfigFileExtension = "config", Watch = true)]
diff --git a/ToolLib.Log/Logger/log4net.config b/ToolLib.Log/Logger/log4net.config
new file mode 100644
index 0000000..1428ef1
--- /dev/null
+++ b/ToolLib.Log/Logger/log4net.config
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file