PostSharpCachingTroubleshooting Caching
Open sandboxFocusImprove this doc

Troubleshooting Caching

If you need to troubleshoot the caching aspect, you can enable logging for this feature. The procedure is different whether or not you are using PostSharp Logging in your application.

Enabling logging of caching with PostSharp Logging

If you use PostSharp Logging for logging, you can enable detailed logging of the caching aspect by enabling the Caching logging role for the whole application or a specific type or namespace.

The following code shows how to log the details of the caching aspect to the system console for the whole application:

LoggingServices.DefaultBackend = new ConsoleLoggingBackend();
LoggingServices.DefaultBackend.DefaultVerbosity.SetMinimalLevel(LogLevel.Debug, LoggingRoles.Caching);

Enabling logging of caching with System.Diagnostics

If you are not using PostSharp Logging, you can enable logging of the caching aspect by configuring the TraceSource named PostSharp.Cache in you app.config or web.config file:

<?xml version="1.0" encoding="utf-8" ?>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
            <source name="PostSharp.Cache" switchName="PostSharp.Cache" >
                    <add name="console" />
            <add name="PostSharp.Cache" value="-1" />
            <add name="console" type="System.Diagnostics.ConsoleTraceListener" initializeData="false"/>
        <trace autoflush="true" indentsize="4">
                <add name="console" />

See Also

Other Resources

Getting Started with PostSharp Logging