Skip to content

a9634b09 46a9 5556 b243 d37a6c53bf99

Axel Kesseler edited this page Mar 1, 2023 · 2 revisions

LogLevelMessageExtension.Message(TContext, TScope) Method (ILogger(TContext), TScope, Exception)

This method writes the exception for current TContext taking provided scope into the logger using Message as logging level.

Namespace: Plexdata.LogWriter.Extensions
Assembly: Plexdata.LogWriter.Abstraction (in Plexdata.LogWriter.Abstraction.dll) Version: 1.0.7.1

Syntax

C#

public static void Message<TContext, TScope>(
	this ILogger<TContext> logger,
	TScope scope,
	Exception exception
)

Parameters

 

logger
Type: Plexdata.LogWriter.Abstraction.ILogger(TContext)
The logger used to write the message.
scope
Type: TScope
The logging scope instance to be used.
exception
Type: System.Exception
The exception to be written.

Type Parameters

 

TContext
The type to get the logging context from. Such a context might be a class and shall help to find out the source that causes a particular logging message.
TScope
The type or a Guid that represents the logging scope.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type ILogger(TContext). When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

The logging context is intended to be some kind of message grouping. Against this background, the context can be used to identify the source (for example a class) of a logging message. In combination with the message scope it would become possible to uniquely identify the caller of a logging message.

The logging scope is intended to be more than just the type name.  

  • If parameter scope is for example of type String then this string is used.
  • If parameter scope is for example of type Guid then the guid's string representation is taken by calling ToString(). Using a Guid as scope type can be seen as some kind of correlation ID, especially if this Guid is the same for multiple calls.
  • If parameter scope is for example of type MemberInfo then the referenced member's Name is taken instead.
  • In all other cases the scope text is either taken from the type's FullName or it is just the Name of type TScope. The usage of full or short name is determined from current settings.
  Be aware, nothing will happen if logger is null or if exception is null.

See Also

Reference

LogLevelMessageExtension Class
Message Overload
Plexdata.LogWriter.Extensions Namespace

Clone this wiki locally