PostSharp [Logging]

  • Get highly detailed logs with method names and parameter values. Turn on/off for each web request.
  • Zero impact on source code. Get started in minutes and keep business logic crystal clear.
  • Completely customizable. Compatible with all logging frameworks.
PostSharp [Logging]

High-Definition Logs: Under Control

You can include the following pieces of data: Doc

You never know what can happen in production. Build logging into your app, but enable it only when needed.

  • Method execution and field changes
  • Parameter and return values
  • Execution time
  • Source code file name and line number
  • Per-Request Logging: Make decisions based on URL, client IP, etc. doc
  • Sampled Logging: Random x% or throttled x per second.
  • Edit your configuration directly in the cloud drive. No restart is required.
  • Control every namespace and type individually.

No Impact on Source Code

// Log all public methods of Contoso.BusinessLayer.
[assembly: Log( AttributePriority = 1,
                AttributeTargetTypes = "Contoso.BusinessLayer.*,
                AttributeTargetMemberAttributes = MulticastAttributes.Public)]

// Exclude property getters and setters.
[assembly: Log( AttributePriority = 2,
                AttributeTargetMembers = "regex:(get|set)_.*")]
  • Target thousands of methods with a single line of code based on namespace, name, or visibility. doc
  • Create more complex filters with System.Reflection in C#. doc
  • Remove from release builds with #if DEBUG.

Customizable to Your Needs

PostSharp Logging integrates with the .NET logging frameworks listed below. If your preferred framework is not among them, you can implement an adapter.

Parameter Formatters – Customize how parameter values are rendered, even with external types. doc

Enable/Disable Features – Most features can be manually enabled or disabled, allowing you to use only the features you need. If you don't need parameter names, you can disable them. doc

Custom Logging Framework – You can build an adapter for any VB/C# logging framework, including structured ones. doc example

Custom Transactions – If you prefer per-request logging but your application is not a web server, we've got you covered. Documentation

Engineered for Modern Deployments

Distributed Logging

If you're using a central logging server like Elasticsearch, correlating traces of a distributed application is a simple two-line task. Documentation See an example

Structured Logging

When used with a structured logging framework such as Serilog, PostSharp Logging separates message templates from variable parameters, making it easy to search, filter, and bucketize log records. Documentation

Exceptional Performance

At PostSharp, we have an obsession with performance. PostSharp Logging outperforms hand-written code in most cases. When logging is disabled, the performance impact is almost negligible. Documentation

No Agent Required

PostSharp Logging instruments your code at build time, eliminating the need for any installations on end-user devices. It is compatible with desktop, mobile, and server devices.

No Monthly or Per-GB Costs

PostSharp Logging allows you to bring your own storage. Your data will be stored wherever you prefer.

Privacy & Security Awareness

The [NotLogged] attribute in PostSharp Logging helps prevent passwords and confidential data from leaking into logs. doc

Fail-Safe

We understand that things break. That's why we've implemented an aggressive circuit breaker in PostSharp Logging. This ensures that any failure in logging doesn't bring down your mission-critical operations. doc

Add highly detailed logging to your .NET projects free of charge for development and testing machines.

Add PostSharp Logging to your application and enable Developer Mode. Applications will cease logging one day after they have been compiled. This feature is excellent for diagnosing your code on development and test machines.