LoggerExtensions.BeginScope(ILogger, String, Object[]) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
格式化訊息並建立範圍。
public:
[System::Runtime::CompilerServices::Extension]
static IDisposable ^ BeginScope(Microsoft::Extensions::Logging::ILogger ^ logger, System::String ^ messageFormat, ... cli::array <System::Object ^> ^ args);
public static IDisposable BeginScope (this Microsoft.Extensions.Logging.ILogger logger, string messageFormat, params object[] args);
public static IDisposable BeginScope (this Microsoft.Extensions.Logging.ILogger logger, string messageFormat, params object?[] args);
public static IDisposable? BeginScope (this Microsoft.Extensions.Logging.ILogger logger, string messageFormat, params object?[] args);
static member BeginScope : Microsoft.Extensions.Logging.ILogger * string * obj[] -> IDisposable
<Extension()>
Public Function BeginScope (logger As ILogger, messageFormat As String, ParamArray args As Object()) As IDisposable
參數
- messageFormat
- String
以訊息範本格式來格式化記錄訊息的字串。 範例: "User {User} logged in from {Address}"
- args
- Object[]
物件陣列,包含零或多個要格式化的物件。
傳回
可處置的範圍物件。 可以是 null。
範例
using(logger.BeginScope("Processing request from {Address}", address)) { }