Show / Hide Table of Contents

BeginScope Method

BeginScope(Logger, string, params object?[])

Formats the message and creates a scope.

C#
[Obsolete("Obsolete, use equivalent ILogger method, or view the changelog for further instruction.")]
public static IDisposable? BeginScope(this Logger logger, string messageFormat, params object?[] args)

Parameters

Type Name Description
Logger logger

The Logger to create the scope in.

string messageFormat

Format string of the log message in message template format. Example: "User {User} logged in from {Address}"

object[] args

An object array that contains zero or more objects to format.

Returns

IDisposable

A disposable scope object. Can be null.

Examples

using(logger.BeginScope("Processing request from {Address}", address)) { }

In this article
Back to top Generated by DocFX