Open sandboxFocus

Class LoggingProfile

Logging profiles are named configurations of logging aspects and influence the way PostSharp generates the code instrumentation. They are typically instantiated in postsharp.config.

Inheritance
LoggingProfile
Namespace: PostSharp.Patterns.Diagnostics
Assembly: PostSharp.Patterns.Diagnostics.dll
Syntax
[Serializer(typeof(LoggingProfile.Serializer))]
public class LoggingProfile
Remarks

Logging profiles can be referred to from the LogAttribute. There are three system-defined logging profiles: Default (the default profile for LogAttribute), Exceptions (default for LogExceptionAttribute), and Audit (default for AuditAttribute).

Define or change a profile with a LoggingProfile element under Logging/Profiles in postsharp.config. The settings of a profile with the name of a system-defined profile override the settings of that profile. To use a new profile, pass its name to the LogAttribute(string) constructor. Because profiles affect the generated code, rebuild the project after changing them.

Profiles contain only build-time options. Run-time options, such as the formatting of text records, are set on the Options property of the backend, and apply to all profiles that use this backend.

Constructors

Name Description
LoggingProfile()
LoggingProfile(PortableFormatterConstructorContext)

Properties

Name Description
AllowDynamicEnabling

Gets or sets a value indicating whether logging can be dynamically enabled or disabled after initialization. The default value of this property is true. When it is set to false, PostSharp generates code that allows the JIT compiler to completely remove logging instructions for types that are not enabled.

Backend

Gets the LoggingBackend associated with the current profile.

DefaultOptions

Gets or sets the options for "normal" records, for example method entry, method success, or value change.

Description

Gets or sets a human-readable description for the current profile. The description is used only when representing the profile in PostSharp Tools for Visual Studio.

EnabledRecordKinds

Gets or sets the set of record kinds that are enabled for the given profile. Change it with care. Not all combinations are tested.

ExceptionOptions

Gets or sets the options for "exception" records, for example method exceptions or slow executions.

ExecutionTimeThreshold

Gets or sets the warning threshold, in milliseconds. If the execution of a method takes longer than that, its success is logged with Warning, and the time it took is logged. If the value is 0, this feature is disabled.

IncludeAwaitedTask

Gets or sets a value indicating whether the operand of the await operator should be included in the log.

IncludeExecutionTime

Gets or sets a value indicating whether the execution time of a method should be tracked and logged on exit.

IncludeSourceLineInfo

Gets or sets a value indicating whether source-line information should be included in the log.

Name

Gets or sets the name of the current profile. The name of the profile should match the constructor argument of the LogAttribute aspect.

Role

Gets or sets the role of the current profile. Profiles of different roles can have different run-time options, including different backends. See Roles to access role-based run-time options.

Methods

Name Description
EnsureNotFrozen()

Throws an InvalidOperationException if the Freeze() method has been called on this object.

Freeze()

Prevents changes in the current object.

GetAbstractSource(Type)

Gets the LoggingAbstractSource for a given Type in the current profile.

ToString()

See Also