Skip to content

Commit 693ce1f

Browse files
authored
Update nodejs.md
added a new section for sdk log collection/self diagnostics Please refer to lines 455 to 472 I am an Engineer from the Application Insights team who built this lab and also contributed to TSGs I appreciate if the changes can be reviewed and published and, if my name is listed as a contributor to help me in my connect discussion.
1 parent e729282 commit 693ce1f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

articles/azure-monitor/app/nodejs.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,27 @@ These properties are client specific, so you can configure `appInsights.defaultC
452452
| correlationIdRetryIntervalMs | The time to wait before retrying to retrieve the ID for cross-component correlation. (Default is `30000`.) |
453453
| correlationHeaderExcludedDomains| A list of domains to exclude from cross-component correlation header injection. (Default. See [Config.ts](https://github.com/Microsoft/ApplicationInsights-node.js/blob/develop/Library/Config.ts).)|
454454

455+
##**How do I customize logs collection?**
456+
457+
By default, Application Insights Node.js SDK logs at warning level to console.
458+
459+
To spot and diagnose issues with Application Insights, "Self-diagnostics" can be enabled. This means collection of internal logging from Application Insights Node.js SDK.
460+
461+
The following code demonstrates how to enable debug logging as well and generate telemetry for internal logs.
462+
463+
let appInsights = require("applicationinsights");
464+
appInsights.setup("<YOUR_CONNECTION_STRING>")
465+
.setInternalLogging(true, true) // Enable both debug and warning logging
466+
.setAutoCollectConsole(true, true) // Generate Trace telemetry for winston/bunyan and console logs
467+
.start();
468+
469+
Logs could be put into local file using APPLICATIONINSIGHTS_LOG_DESTINATION environment variable, supported values are file and file+console, a file named applicationinsights.log will be generated on tmp folder by default, including all logs, /tmp for *nix and USERDIR\\AppData\\Local\\Temp for Windows. Log directory could be configured using APPLICATIONINSIGHTS_LOGDIR environment variable.
470+
471+
process.env.APPLICATIONINSIGHTS_LOG_DESTINATION = "file+console";
472+
process.env.APPLICATIONINSIGHTS_LOGDIR = "C:\\applicationinsights\\logs";
473+
474+
// Application Insights SDK setup....
475+
455476
## Troubleshooting
456477

457478
[!INCLUDE [azure-monitor-app-insights-test-connectivity](../../../includes/azure-monitor-app-insights-test-connectivity.md)]

0 commit comments

Comments
 (0)