Reputation: 679
I'm trying to configure Microsoft Insights in an app based in Vue. My idea is to sent specific logs there, with the info that I consider relevant. I've created the resource in Azure and got its instrumentation key. Looking at the documentation we can load this like this
import { ApplicationInsights } from '@microsoft/applicationinsights-web'
const appInsights = new ApplicationInsights({ config: {
instrumentationKey: 'YOUR_INSTRUMENTATION_KEY_GOES_HERE'
} });
appInsights.loadAppInsights();
appInsights.trackPageView();
My question is, how can I send specific logs? I'm looking for something similar to:
appInsights.log('Info that I want to log');
Upvotes: 0
Views: 267
Reputation: 29711
You can use trackTrace:
appInsights.trackTrace({message: 'Info that I want to log'});
traces are generally used for diagnostic logging. If you want to capture certain business related events you can use trackEvent:
appInsights.trackEvent({
name: 'some event',
properties: { // accepts any type
prop1: 'string',
prop2: 123.45,
prop3: { nested: 'objects are okay too' }
}
});
Custom properties can be included in your telemetry through the properties named argument. This can be done with any of the Track APIs like in the example above.
For more background, see the GitHub repo
Upvotes: 2