PostSharpLoggingAdding Manual Logging
Open sandboxFocusImprove this doc

Adding Manual Logging

When you're using the LogAttribute aspect, PostSharp automatically generates code that emits log records before and after the execution of a method. However, there are times when you would want to write your own records - for example, you may want to log a custom error or warning. Such messages are to be displayed even when trace-level logging is disabled, and when it is enabled, they are to appear in the right context and with the proper indentation.

For these scenarios, you can use the methods provided by the LogSource class.

In this chapter

Section Description
Writing Custom Messages This article shows how to write standalone messages to the log. It discusses the difference between formatted-text messages and semantic messages, the latter being more appropriate for statistical processing.
Working with Custom Activities This article describes how to define custom activities, i.e. nested scopes of operations that have a description and can succeed or fail.
Adding Properties to Messages and Activities This article shows how to add and configure properties to your custom messages and custom activities.