Reputation: 31
I was trying to use application Insights as my logging backend from postsharp references. I have setup the application insights and was able to see live metrics. But I am not quite sure if postsharp logging alone is able to write to application insights.
My code in Program.cs
using PostSharp.Patterns.Diagnostics;
using PostSharp.Patterns.Diagnostics.Backends.ApplicationInsights;
LoggingServices.DefaultBackend = new ApplicationInsightsLoggingBackend("InstrumentationKey");
GlobalAspects.cs file:
using PostSharp.Patterns.Diagnostics;
using PostSharp.Extensibility;
// This file contains registration of aspects that are applied to several classes of this project.
[assembly: Log(AttributeTargetTypeAttributes=MulticastAttributes.Public, AttributeTargetMemberAttributes=MulticastAttributes.Public)]
Do I need to setup anyhting in my program.cs in order to completely make use of postsharp logging to write to applicationinsights.
Upvotes: 1
Views: 129
Reputation: 1408
You need to set the default verbosity of the Application Insights logging backend to Trace to get the method call log records.
LoggingServices.DefaultBackend.DefaultVerbosity.SetMinimalLevel(LogLevel.Trace);
Upvotes: 0