PostSharpAPI ReferencePost­Sharp.​Patterns.​DiagnosticsLogging­ServicesGet­Source
Open sandboxFocus

LoggingServices.GetSource Method

GetSource(String, Type)

Returns a LoggingTypeSource for the given role and type.

Declaration
public static LoggingTypeSource GetSource(string role, Type type)
Parameters
Type Name Description
System.String role

The role. Typically one of the constants of the LoggingRoles type, or a custom role.

System.Type type

The type.

Returns
Type Description
LoggingTypeSource

The LoggingTypeSource for role and type. If no LoggingTypeSource exists for this role and type, this method shall create a new LoggingTypeSource.

Remarks

This method returns a LoggingTypeSource for the LoggingBackend currently configured for the given role. Instances of the LoggingTypeSource classes are not shared by different instances of the LoggingBackend class, however several roles can share the same LoggingBackend instance. Therefore, you should configure a LoggingTypeSource after, and not before, assigning a LoggingBackend to the DefaultBackend property or a LoggingRoleConfiguration.

GetSource(String, String)

Returns a LoggingNamespaceSource for the given role and, optionally, namespace.

Declaration
public static LoggingNamespaceSource GetSource(string role, string ns = null)
Parameters
Type Name Description
System.String role

The role. Typically one of the constants of the LoggingRoles type, or a custom role.

System.String ns

The namespace for which the LoggingNamespaceSource is requested, or null if the LoggingNamespaceSource is requested for the root namespace.

Returns
Type Description
LoggingNamespaceSource

The LoggingNamespaceSource for role and ns. If no LoggingNamespaceSource exists for this role and type, this method shall create a new LoggingNamespaceSource.

Remarks

This method returns a LoggingNamespaceSource for the LoggingBackend currently configured for the given role. Instances of the LoggingNamespaceSource classes are not shared by different instances of the LoggingBackend class, however several roles can share the same LoggingBackend instance. Therefore, you should configure a LoggingNamespaceSource after, and not before, assigning a LoggingBackend to the DefaultBackend property or a LoggingRoleConfiguration.