# Variable telemetry`Const`

telemetry: CompoundTelemetryClient = ...

Use for telemetry logging. Use this instead of console.log and similiar. It is used internally by the Twinfinity Client API. By default logs are output to console. If application insights is detected in the page, when `telemetry` is first accessed, then it will also automatically log to application insights.

Simplest way to forward logs to application insights is to use the "Snippet based setup" from https://docs.microsoft.com/en-us/azure/azure-monitor/app/javascript. Ensure that the snippet comes before all other scripts in the page.

#### Example

    // Log a warning.
    telemetry.traceTrace({message: "log message", severityLevel: 2});

#### Example

    // Explicitly register existing application insights instance. See "npm based setup" at
    // https://docs.microsoft.com/en-us/azure/azure-monitor/app/javascript for how to get the instance.
    telemetry.set('myApplicationInsights', applicationInsightsInstance);
    telemetry.traceTrace({message: "log message" }); // Log a debug log. Same output as console.log

#### Example

    // Explicitly register custom telemetryclient
    class CustomClient implements TwinfinityTelemetryClient { ... }
    telemetry.set('customclient', new CustomClient());
    telemetry.isConsoleLoggingEnabled = false; // Disable console logging
    // Log a debug log. Will be forwarded to the custom client. If
    // application insights was registered in the page then the log will be sent
    // there too.
    telemetry.traceTrace({message: "log message" });