PostSharp6.2/API Reference/Post­Sharp.​Patterns.​Diagnostics Namespace/Log­Source Class

LogSource Class

Allow to write log messages and trace the execution of activities. This class is optimized for use with C# 7.2 or later. For previous compiler versions, consider using the legacy Logger class.
Inheritance Hierarchy
System.Object
  PostSharp.Patterns.Diagnostics.LogSource

Namespace:  PostSharp.Patterns.Diagnostics
Assembly:  PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 6.2.11.0 (6.2.11.0)
Syntax
C#
public sealed class LogSource

The LogSource type exposes the following members.

Properties
  NameDescription
Public propertyCritical
Exposes methods that allow to write messages and open activities with the Critical severity.
Public propertyCurrentContext
Public propertyDebug
Exposes methods that allow to write messages and open activities with the Debug severity.
Public propertyDefault
Exposes methods that allow to write messages and open activities with the default severity of the current LogSource. The default severity is Debug, unless it has been overwritten by the WithLevels(LogLevel, LogLevel) method.
Public propertyError
Exposes methods that allow to write messages and open activities with the Error severity.
Public propertyFailure
Exposes methods that allow to write messages and open activities with the default failure severity of the current LogSource. The default severity is Error, unless it has been overwritten by the WithLevels(LogLevel, LogLevel) method.
Public propertyInfo
Exposes methods that allow to write messages and open activities with the Info severity.
Public propertyNone
Exposes methods that allow to open activities with the None severity. Such activities are never displayed, but they can define properties that can be inherited to children activities and messages.
Public propertyTrace
Exposes methods that allow to write messages and open activities with the Trace severity.
Public propertyWarning
Exposes methods that allow to write messages and open activities with the Warning severity.
Methods
  NameDescription
Public methodForCurrentType
Gets a new LogSource keeping all the configuration of the current instance, but for the calling type.
Public methodForType
Gets a new LogSource keeping all the configuration of the current instance, but for a different type.
Public methodStatic memberGet
Gets a LogSource for the calling type.
Public methodIsEnabled
Determines whether logging is enabled in the current LogSource for a given LogLevel.
Public methodWithLevel
Exposes methods that allow to write messages and open activities with a specified LogLevel.
Public methodWithLevels
Returns a new LogSource based on the current instance, but overrides the default logging levels.
Public methodWriteExecutionPoint
Emits a log record with the source file and line of the caller.
Remarks

Instances of this class are immutable.

You should typically have one instance of this class per type. Use Get() or GetLogSource(ILoggerFactory2, Type) to get an instance of this class for the current type.

See Also