mirror of
https://github.com/dotnetcore/Util.git
synced 2026-10-29 03:26:31 +08:00
25 lines
779 B
C#
25 lines
779 B
C#
namespace Util.Logging.Tests;
|
|
|
|
/// <summary>
|
|
/// 日志上下文访问器
|
|
/// </summary>
|
|
public class LogContextAccessor : ILogContextAccessor {
|
|
/// <summary>
|
|
/// 日志上下文键名
|
|
/// </summary>
|
|
public const string LogContextKey = "Util.Logging.LogContext";
|
|
|
|
/// <summary>
|
|
/// 日志上下文
|
|
/// </summary>
|
|
public LogContext Context {
|
|
get {
|
|
var slot = System.Threading.Thread.GetNamedDataSlot( LogContextKey );
|
|
return Util.Helpers.Convert.To<LogContext>( System.Threading.Thread.GetData( slot ) );
|
|
}
|
|
set {
|
|
var slot = System.Threading.Thread.GetNamedDataSlot( LogContextKey );
|
|
System.Threading.Thread.SetData( slot, value );
|
|
}
|
|
}
|
|
} |