Skip to content

Class Log ​

Namespace: Tool.Utils
Assembly: Tool.Net.dll

日志工具类

csharp
public sealed class Log

Inheritance ​

object ← Log

Inherited Members ​

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Extension Methods ​

ObjectExtension.Add<T>(object, object, object), ObjectExtension.CopyEntity(object, object, params string[]), ObjectExtension.EntityToJson(object), ObjectExtension.EntityToJson(object, bool), ObjectExtension.EntityToJson(object, bool, string), DictionaryExtension.GetDictionary(object), TypeExtension.GetFieldKey(object, string, out bool), TypeExtension.GetFieldKey<T>(object, string, out bool), TypeExtension.GetFieldKey(object, Type, string, out bool), ObjectExtension.GetIntPtr(object), ObjectExtension.GetIntPtrInt(object), TypeExtension.GetPropertieFind(object, string, bool), TypeExtension.GetProperties(object), TypeExtension.GetPropertyKey(object, string, out bool), TypeExtension.GetPropertyKey<T>(object, string, out bool), TypeExtension.GetPropertyKey(object, Type, string, out bool), TypeExtension.GetValue(object, PropertyDescriptor), TypeExtension.GetValue(object, string, bool), TypeExtension.GetValue(object, string), ObjectExtension.Read<T>(object, object, int, int), ObjectExtension.Read<T>(object, int, object, int, int), DictionaryExtension.SetDictionary(object, IDictionary<string, object>), TypeExtension.SetFieldKey(object, string, object), TypeExtension.SetFieldKey<T>(object, string, object), TypeExtension.SetFieldKey(object, Type, string, object), TypeExtension.SetPropertyKey(object, string, object), TypeExtension.SetPropertyKey<T>(object, string, object), TypeExtension.SetPropertyKey(object, Type, string, object), TypeExtension.SetValue(object, PropertyDescriptor, object), TypeExtension.SetValue(object, string, object, bool), TypeExtension.SetValue(object, string, object), ObjectExtension.ToBase64String(object), ObjectExtension.ToBytes(object), ObjectExtension.ToBytes(object, out Type), DictionaryExtension.ToDictionary(object), DictionaryExtension.ToDictionary<T>(object), DictionaryExtension.ToIDictionary(object), DictionaryExtension.ToIDictionary<T>(object), ObjectExtension.ToJson(object), ObjectExtension.ToJson(object, JsonSerializerOptions), ObjectExtension.ToJsonWeb(object), ObjectExtension.ToJsonWeb(object, Action<JsonSerializerOptions>), ObjectExtension.ToTryVar<T>(object, T), ObjectExtension.ToVar<T>(object), ObjectExtension.ToVar(object, Type, bool), ObjectExtension.ToVar(object, string), ObjectExtension.ToXml(object)

Fields ​

LogFilePath ​

csharp
public const string LogFilePath = "Log\\"

Field Value ​

string

Properties ​

IgnoreMethodName ​

用于打印异常信息时,忽略掉堆栈中的部分方法。

csharp
public HashSet<string> IgnoreMethodName { get; }

Property Value ​

HashSet<string>

Instance ​

实现单例,不建议直接调用。

csharp
public static Log Instance { get; }

Property Value ​

Log

IsAlive ​

日志任务是否已经启动了(没有启动时 false,启动后发生意外时 false, 其余时候一直都是 true )

csharp
public bool IsAlive { get; }

Property Value ​

bool

IsEnd ​

日志结束(可以获取日志是否出现了,异常导致终止)

csharp
public static bool IsEnd { get; }

Property Value ​

bool

IsMoveNext ​

是否在方法名为《MoveNext》时验证是否是异步函数生成,获取显示实际名称

csharp
public bool IsMoveNext { get; set; }

Property Value ​

bool

Methods ​

Debug(string) ​

一般日志输出

csharp
public static void Debug(string msg)

Parameters ​

msg string

日志内容

Debug(string, string) ​

一般日志输出

csharp
public static void Debug(string msg, string LogFilePath)

Parameters ​

msg string

日志内容

LogFilePath string

提供的路径可以是相对路径也可以是绝对路径

Debug(string, Exception) ​

一般日志输出

csharp
public static void Debug(string msg, Exception ex)

Parameters ​

msg string

日志内容

ex Exception

异常对象

Debug(string, Exception, string) ​

一般日志输出

csharp
public static void Debug(string msg, Exception ex, string LogFilePath)

Parameters ​

msg string

日志内容

ex Exception

异常对象

LogFilePath string

提供的路径可以是相对路径也可以是绝对路径

EnqueueMessage(string, FlashLogLevel, Exception, string) ​

写日志

csharp
public void EnqueueMessage(string message, FlashLogLevel level, Exception ex = null, string logFilePath = null)

Parameters ​

message string

日志文本

level FlashLogLevel

等级

ex Exception

Exception

logFilePath string

提供的路径可以是相对路径也可以是绝对路径

Error(string) ​

异常错误

csharp
public static void Error(string msg)

Parameters ​

msg string

日志内容

Error(string, string) ​

异常错误

csharp
public static void Error(string msg, string LogFilePath)

Parameters ​

msg string

日志内容

LogFilePath string

提供的路径可以是相对路径也可以是绝对路径

Error(string, Exception) ​

异常错误

csharp
public static void Error(string msg, Exception ex)

Parameters ​

msg string

日志内容

ex Exception

异常对象

Error(string, Exception, string) ​

异常错误

csharp
public static void Error(string msg, Exception ex, string LogFilePath)

Parameters ​

msg string

日志内容

ex Exception

异常对象

LogFilePath string

提供的路径可以是相对路径也可以是绝对路径

Fatal(string) ​

致命的错误

csharp
public static void Fatal(string msg)

Parameters ​

msg string

日志内容

Fatal(string, string) ​

致命的错误

csharp
public static void Fatal(string msg, string LogFilePath)

Parameters ​

msg string

日志内容

LogFilePath string

提供的路径可以是相对路径也可以是绝对路径

Fatal(string, Exception) ​

致命的错误

csharp
public static void Fatal(string msg, Exception ex)

Parameters ​

msg string

日志内容

ex Exception

异常对象

Fatal(string, Exception, string) ​

致命的错误

csharp
public static void Fatal(string msg, Exception ex, string LogFilePath)

Parameters ​

msg string

日志内容

ex Exception

异常对象

LogFilePath string

提供的路径可以是相对路径也可以是绝对路径

Info(string) ​

信息日志

csharp
public static void Info(string msg)

Parameters ​

msg string

日志内容

Info(string, string) ​

信息日志

csharp
public static void Info(string msg, string LogFilePath)

Parameters ​

msg string

日志内容

LogFilePath string

提供的路径可以是相对路径也可以是绝对路径

Info(string, Exception) ​

信息日志

csharp
public static void Info(string msg, Exception ex)

Parameters ​

msg string

日志内容

ex Exception

异常对象

Info(string, Exception, string) ​

信息日志

csharp
public static void Info(string msg, Exception ex, string LogFilePath)

Parameters ​

msg string

日志内容

ex Exception

异常对象

LogFilePath string

提供的路径可以是相对路径也可以是绝对路径

Warn(string) ​

警告日志

csharp
public static void Warn(string msg)

Parameters ​

msg string

日志内容

Warn(string, string) ​

警告日志

csharp
public static void Warn(string msg, string LogFilePath)

Parameters ​

msg string

日志内容

LogFilePath string

提供的路径可以是相对路径也可以是绝对路径

Warn(string, Exception) ​

警告日志

csharp
public static void Warn(string msg, Exception ex)

Parameters ​

msg string

日志内容

ex Exception

异常对象

Warn(string, Exception, string) ​

警告日志

csharp
public static void Warn(string msg, Exception ex, string LogFilePath)

Parameters ​

msg string

日志内容

ex Exception

异常对象

LogFilePath string

提供的路径可以是相对路径也可以是绝对路径

基于Apache-2.0协议开源