Skip to content

Commit 4822612

Browse files
Merge pull request #109319 from Ashi-Sunnam/patch-5
Update nodejs.md
2 parents 874698f + 51a117c commit 4822612

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

articles/azure-monitor/app/nodejs.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,29 @@ 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 the Application Insights Node.js SDK.
460+
461+
The following code demonstrates how to enable debug logging as well as generate telemetry for internal logs.
462+
463+
```
464+
let appInsights = require("applicationinsights");
465+
appInsights.setup("<YOUR_CONNECTION_STRING>")
466+
.setInternalLogging(true, true) // Enable both debug and warning logging
467+
.setAutoCollectConsole(true, true) // Generate Trace telemetry for winston/bunyan and console logs
468+
.start();
469+
470+
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.
471+
472+
process.env.APPLICATIONINSIGHTS_LOG_DESTINATION = "file+console";
473+
process.env.APPLICATIONINSIGHTS_LOGDIR = "C:\\applicationinsights\\logs";
474+
475+
// Application Insights SDK setup....
476+
```
477+
455478
## Troubleshooting
456479

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

0 commit comments

Comments
 (0)