When you use the LogAttribute aspect, PostSharp automatically generates code that emits log records before and after the execution of a method. However, you may want to write your own records, for example to log a custom error or warning. Such messages should be displayed even when trace-level logging is disabled. When trace-level logging is enabled, they should 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, that is, 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. |