PostSharp6.1/Logging/Upgrading Logging from an Earlier Version

Upgrading Logging from an Earlier Version

Update from PostSharp 6.0 or earlier

The API to deal with manual messages and custom activities (see Adding Custom Log Records Manually) has been completely revamped. The old API, based on the Logger, still works but is no longer recommended for new developments. However, there is no compelling reasons to replace it with the new LogSource-based API in existing developments.

For existing code, we suggest you selectively disable the obsolescence warning using a #pragma directive:

#pragma warning disable 618
  Logger.GetLogger().Write( LogLevel.Error, "Text" );
#pragma warning restore 618
Update from PostSharp 4.3 or earlier.

PostSharp Logging has been completely rewritten between PostSharp 4.3 and PostSharp 5.0. There are some significant breaking changes that you will need to take into account.

To migrate your logging from PostSharp 4.3 or earlier:

  1. Uninstall all PostSharp.Patterns.Diagnostics.* packages except PostSharp.Patterns.Diagnostics itself

  2. Upgrade all PostSharp packages.

  3. Add the package for your backend logging framework to the start-up project (instead of adding it to all projects prior to PostSharp 5.0) and configure it at run-time as described in Adding Detailed Logging to your Solution.

  4. Migrate the logging profiles to the new format as described in Adding Detailed Logging to your Solution. Some options that used to be accessible from logging profiles are now run-time options and are described in Customizing the Appearance of Log Records.