Repository: microsoft/ApplicationInsights-node.js
Pull request #1256 (2024-01-08 22:26:12)

[Beta] Use OpenTelemetry diag API
Related to
https://github.com/Azure/azure-sdk-for-js/pull/28183


Patch:
diff --git a/src/logs/api.ts b/src/logs/api.ts
index 0e5c053..ab76de1 100644
--- a/src/logs/api.ts
+++ b/src/logs/api.ts
@@ -3,7 +3,7 @@
 
 import { Logger as OtelLogger, LogRecord, logs } from "@opentelemetry/api-logs";
 import { LogRecord as SDKLogRecord } from "@opentelemetry/sdk-logs";
-import { Attributes } from "@opentelemetry/api";
+import { Attributes, diag } from "@opentelemetry/api";
 import { IdGenerator, RandomIdGenerator } from "@opentelemetry/sdk-trace-base";
 
 import * as Contracts from "../declarations/contracts";
@@ -17,7 +17,6 @@ import {
     TelemetryExceptionData,
     TelemetryExceptionDetails
 } from "../declarations/generated";
-import { Logger } from "../shared/logging";
 import { Util } from "../shared/util";
 import { parseStack } from "./exceptions";
 
@@ -47,7 +46,7 @@ export class LogApi {
             );
             this._logger.emit(logRecord);
         } catch (err) {
-            Logger.getInstance().error("Failed to send telemetry.", err);
+            diag.error("Failed to send telemetry.", err);
         }
     }
 
@@ -62,7 +61,7 @@ export class LogApi {
             );
             this._logger.emit(logRecord);
         } catch (err) {
-            Logger.getInstance().error("Failed to send telemetry.", err);
+            diag.error("Failed to send telemetry.", err);
         }
     }
 
@@ -75,7 +74,7 @@ export class LogApi {
             const logRecord = this._traceToLogRecord(telemetry) as SDKLogRecord;
             this._logger.emit(logRecord);
         } catch (err) {
-            Logger.getInstance().error("Failed to send telemetry.", err);
+            diag.error("Failed to send telemetry.", err);
         }
     }
 
@@ -93,7 +92,7 @@ export class LogApi {
             ) as SDKLogRecord;
             this._logger.emit(logRecord);
         } catch (err) {
-            Logger.getInstance().error("Failed to send telemetry.", err);
+            diag.error("Failed to send telemetry.", err);
         }
     }
 
@@ -106,7 +105,7 @@ export class LogApi {
             const logRecord = this._eventToLogRecord(telemetry);
             this._logger.emit(logRecord);
         } catch (err) {
-            Logger.getInstance().error("Failed to send telemetry.", err);
+            diag.error("Failed to send telemetry.", err);
         }
     }
 
@@ -142,7 +141,7 @@ export class LogApi {
             return record;
         }
         catch (err) {
-            Logger.getInstance().warn("Failed to convert telemetry event to Log Record.", err);
+            diag.warn("Failed to convert telemetry event to Log Record.", err);
         }
     }
 
diff --git a/src/logs/diagnostic-channel/initialization.ts b/src/logs/diagnostic-channel/initialization.ts
index b6db3da..62c1170 100644
--- a/src/logs/diagnostic-channel/initialization.ts
+++ b/src/logs/diagnostic-channel/initialization.ts
@@ -3,7 +3,8 @@
 
 // Don't reference modules from these directly. Use only for types.
 import * as DiagChannelPublishers from "diagnostic-channel-publishers";
-import { Logger } from "../../shared/logging";
+import { diag } from "@opentelemetry/api";
+
 
 const TAG = "DiagnosticChannel";
 let isInitialized = false;
@@ -22,7 +23,7 @@ export function enablePublishers() {
 
         for (const mod in modules) {
             modules[mod].enable();
-            Logger.getInstance().info(TAG, `Subscribed to ${mod} events`);
+            diag.info(TAG, `Subscribed to ${mod} events`);
         }
     }
 }
diff --git a/src/main.ts b/src/main.ts
index 15dff1c..7abeac0 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -2,7 +2,7 @@
 // Licensed under the MIT license.
 
 import { shutdownAzureMonitor as distroShutdownAzureMonitor, useAzureMonitor as distroUseAzureMonitor } from "@azure/monitor-opentelemetry";
-import { ProxyTracerProvider, metrics, trace } from "@opentelemetry/api";
+import { ProxyTracerProvider, diag, metrics, trace } from "@opentelemetry/api";
 import { logs } from "@opentelemetry/api-logs";
 import { MeterProvider, PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
 import { BatchLogRecordProcessor, LoggerProvider } from "@opentelemetry/sdk-logs";
@@ -11,7 +11,6 @@ import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
 import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
 import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
 
-import { Logger } from "./shared/logging";
 import { AutoCollectConsole } from "./logs/console";
 import { AutoCollectExceptions } from "./logs/exceptions";
 import { AzureMonitorOpenTelemetryOptions } from "./types";
@@ -66,7 +65,7 @@ export async function flushAzureMonitor() {
         await (trace.getTracerProvider() as BasicTracerProvider).forceFlush();
         await (logs.getLoggerProvider() as LoggerProvider).forceFlush();
     } catch (err) {
-        Logger.getInstance().error("Failed to flush telemetry", err);
+        diag.error("Failed to flush telemetry", err);
     }
 }
 
@@ -80,7 +79,7 @@ function _addOtlpExporters(internalConfig: ApplicationInsightsConfig) {
             (metrics.getMeterProvider() as MeterProvider).addMetricReader(otlpMetricReader);
         }
         catch (err) {
-            Logger.getInstance().error("Failed to set OTLP Metric Exporter", err);
+            diag.error("Failed to set OTLP Metric Exporter", err);
         }
     }
     if (internalConfig.otlpLogExporterConfig?.enabled) {
@@ -90,7 +89,7 @@ function _addOtlpExporters(internalConfig: ApplicationInsightsConfig) {
             (logs.getLoggerProvider() as LoggerProvider).addLogRecordProcessor(otlpLogProcessor);
         }
         catch (err) {
-            Logger.getInstance().error("Failed to set OTLP Log Exporter", err);
+            diag.error("Failed to set OTLP Log Exporter", err);
         }
     }
     if (internalConfig.otlpTraceExporterConfig?.enabled) {
@@ -100,7 +99,7 @@ function _addOtlpExporters(internalConfig: ApplicationInsightsConfig) {
             ((trace.getTracerProvider() as ProxyTracerProvider).getDelegate() as NodeTracerProvider).addSpanProcessor(otlpSpanProcessor);
         }
         catch (err) {
-            Logger.getInstance().error("Failed to set OTLP Trace Exporter", err);
+            diag.error("Failed to set OTLP Trace Exporter", err);
         }
     }
 }
diff --git a/src/metrics/nativeMetrics.ts b/src/metrics/nativeMetrics.ts
index 8305e47..43320a1 100644
--- a/src/metrics/nativeMetrics.ts
+++ b/src/metrics/nativeMetrics.ts
@@ -8,8 +8,7 @@ import {
     PeriodicExportingMetricReader,
     PeriodicExportingMetricReaderOptions,
 } from "@opentelemetry/sdk-metrics";
-import { Histogram, Meter, ObservableGauge, ObservableResult } from "@opentelemetry/api";
-import { Logger } from "../shared/logging";
+import { Histogram, Meter, ObservableGauge, ObservableResult, diag } from "@opentelemetry/api";
 import { ApplicationInsightsConfig } from "../shared/configuration/config";
 
 /**
@@ -88,7 +87,7 @@ export class NativeMetrics {
              // eslint-disable-next-line @typescript-eslint/no-var-requires
             const NativeMetricsEmitter = require("applicationinsights-native-metrics");
             this._emitter = new NativeMetricsEmitter();
-            Logger.getInstance().info("Native metrics module successfully loaded!");
+            diag.info("Native metrics module successfully loaded!");
         } catch (err) {
             // Package not available
             return;
@@ -100,7 +99,7 @@ export class NativeMetrics {
                 // enable self
                 this._emitter.enable(true, this._collectionInterval);
             } catch (err) {
-                Logger.getInstance().error("Native metrics enable failed", err);
+                diag.error("Native metrics enable failed", err);
             }
             // Add histogram data collection
             this._handle = setInterval(() => this._collectHistogramData(), this._collectionInterval);
@@ -144,7 +143,7 @@ export class NativeMetrics {
             }
             this._eventLoopHistogram.record(metrics.total);
         } catch (err) {
-            Logger.getInstance().error("Native metrics failed to get event loop CPU", err);
+            diag.error("Native metrics failed to get event loop CPU", err);
         }
     }
 
@@ -166,7 +165,7 @@ export class NativeMetrics {
                 }
             }
         } catch (err) {
-            Logger.getInstance().error(
+            diag.error(
                 "Native metrics failed to get event Garbage Collection metrics",
                 err
             );
diff --git a/src/shared/configuration/config.ts b/src/shared/configuration/config.ts
index 7f13e1a..8980877 100644
--- a/src/shared/configuration/config.ts
+++ b/src/shared/configuration/config.ts
@@ -3,6 +3,7 @@
 
 import { InstrumentationOptions } from "@azure/monitor-opentelemetry";
 import { AzureMonitorExporterOptions } from "@azure/monitor-opentelemetry-exporter";
+import { diag } from "@opentelemetry/api";
 import {
     Resource,
     ResourceDetectionConfig,
@@ -10,11 +11,9 @@ import {
     envDetectorSync,
 } from "@opentelemetry/resources";
 import { JsonConfig } from "./jsonConfig";
-import { Logger } from "../logging";
 import { AzureMonitorOpenTelemetryOptions, ExtendedMetricType, LogInstrumentationOptions, OTLPExporterConfig } from "../../types";
 
 
-
 export class ApplicationInsightsConfig {
     public logInstrumentationOptions: LogInstrumentationOptions;
     public enableAutoCollectExceptions: boolean;
@@ -174,7 +173,7 @@ export class ApplicationInsightsConfig {
             );
 
         } catch (error) {
-            Logger.getInstance().error("Failed to load JSON config file values.", error);
+            diag.error("Failed to load JSON config file values.", error);
         }
     }
 
diff --git a/src/shared/configuration/jsonConfig.ts b/src/shared/configuration/jsonConfig.ts
index 3a4e7d2..67aeb57 100644
--- a/src/shared/configuration/jsonConfig.ts
+++ b/src/shared/configuration/jsonConfig.ts
@@ -5,7 +5,7 @@ import * as fs from "fs";
 import * as path from "path";
 import { InstrumentationOptions } from "@azure/monitor-opentelemetry";
 import { AzureMonitorExporterOptions } from "@azure/monitor-opentelemetry-exporter";
-import { Logger } from "../logging";
+import { diag } from "@opentelemetry/api";
 import { AzureMonitorOpenTelemetryOptions, LogInstrumentationOptions, OTLPExporterConfig } from "../../types";
 
 
@@ -71,7 +71,7 @@ export class JsonConfig {
             try {
                 jsonString = fs.readFileSync(tempDir, "utf8");
             } catch (err) {
-                Logger.getInstance().info("Failed to read JSON config file: ", err);
+                diag.info("Failed to read JSON config file: ", err);
             }
         }
         try {
@@ -88,7 +88,7 @@ export class JsonConfig {
             this.samplingRatio = jsonConfig.samplingRatio;
             this.instrumentationOptions = jsonConfig.instrumentationOptions;
         } catch (err) {
-            Logger.getInstance().info("Missing or invalid JSON config file: ", err);
+            diag.info("Missing or invalid JSON config file: ", err);
         }
     }
 }
diff --git a/src/shared/logging/index.ts b/src/shared/logging/index.ts
deleted file mode 100644
index a2be8f5..0000000
--- a/src/shared/logging/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-// Copyright (c) Microsoft Corporation.
-// Licensed under the MIT license.
-
-export { Logger } from "./logger";
diff --git a/src/shared/logging/internalAzureLogger.ts b/src/shared/logging/internalAzureLogger.ts
deleted file mode 100644
index 9a2881f..0000000
--- a/src/shared/logging/internalAzureLogger.ts
+++ /dev/null
@@ -1,163 +0,0 @@
-import * as fs from "fs";
-import * as os from "os";
-import * as path from "path";
-import {
-    accessAsync,
-    appendFileAsync,
-    confirmDirExists,
-    getShallowFileSize,
-    readdirAsync,
-    readFileAsync,
-    writeFileAsync,
-    unlinkAsync,
-} from "../util";
-
-export class InternalAzureLogger {
-    private _TAG = "InternalLogger:";
-    private _cleanupTimeOut = 60 * 30 * 1000; // 30 minutes;
-    private _fileCleanupTimer: NodeJS.Timer = null;
-    private _tempDir: string;
-    private _logFileName: string;
-    private _fileFullPath: string;
-    private _backUpNameFormat: string;
-    private _logToFile = false;
-    private _logToConsole = true;
-    private _maxHistory: number;
-    private _maxSizeBytes: number;
-    private _logDestination: string;
-
-    constructor() {
-        this._logDestination = process.env.APPLICATIONINSIGHTS_LOG_DESTINATION; // destination can be one of file, console or file+console
-        if (this._logDestination === "file+console") {
-            this._logToFile = true;
-        }
-        if (this._logDestination === "file") {
-            this._logToFile = true;
-            this._logToConsole = false;
-        }
-        this._maxSizeBytes = 50000;
-        this._maxHistory = 1;
-        this._logFileName = "applicationinsights.log";
-
-        // If custom path not provided use temp folder, /tmp for *nix and USERDIR/AppData/Local/Temp for Windows
-        const logFilePath = process.env.APPLICATIONINSIGHTS_LOGDIR;
-        if (!logFilePath) {
-            this._tempDir = path.join(os.tmpdir(), "appInsights-node");
-        } else {
-            if (path.isAbsolute(logFilePath)) {
-                this._tempDir = logFilePath;
-            } else {
-                this._tempDir = path.join(process.cwd(), logFilePath);
-            }
-        }
-        this._fileFullPath = path.join(this._tempDir, this._logFileName);
-        this._backUpNameFormat = `.${this._logFileName}`; // {currentime}.applicationinsights.log
-
-        if (this._logToFile) {
-            if (!this._fileCleanupTimer) {
-                this._fileCleanupTimer = setInterval(() => {
-                    this._fileCleanupTask();
-                }, this._cleanupTimeOut);
-                this._fileCleanupTimer.unref();
-            }
-        }
-    }
-
-    public async logMessage(message?: any, ...optionalParams: any[]) {
-        try {
-            const args = message ? [message, ...optionalParams] : optionalParams;
-            if (this._logToFile) {
-                await this._storeToDisk(args);
-            }
-            if (this._logToConsole) {
-                // eslint-disable-next-line no-console
-                console.log(...args);
-            }
-        } catch (err) {
-            // eslint-disable-next-line no-console
-            console.log(this._TAG, `Failed to log to file: ${err && err.message}`);
-        }
-    }
-
-    private async _storeToDisk(args: any): Promise<void> {
-        const data = `${args}\r\n`;
-
-        try {
-            await confirmDirExists(this._tempDir);
-        } catch (err) {
-            // eslint-disable-next-line no-console
-            console.log(
-                this._TAG,
-                `Failed to create directory for log file: ${err && err.message}`
-            );
-            return;
-        }
-        try {
-            await accessAsync(this._fileFullPath, fs.constants.F_OK);
-        } catch (err) {
-            // No file create one
-            try {
-                await appendFileAsync(this._fileFullPath, data);
-            } catch (appendError) {
-                // eslint-disable-next-line no-console
-                console.log(
-                    this._TAG,
-                    `Failed to put log into file: ${appendError && appendError.message}`
-                );
-                return;
-            }
-        }
-        // Check size
-        const size = await getShallowFileSize(this._fileFullPath);
-        if (size > this._maxSizeBytes) {
-            await this._createBackupFile(data);
-        } else {
-            await appendFileAsync(this._fileFullPath, data);
-        }
-    }
-
-    private async _createBackupFile(data: string): Promise<void> {
-        try {
-            const buffer = await readFileAsync(this._fileFullPath);
-            const backupPath = path.join(
-                this._tempDir,
-                `${new Date().getTime()}.${this._logFileName}`
-            );
-            await writeFileAsync(backupPath, buffer);
-        } catch (err) {
-            // eslint-disable-next-line no-console
-            console.log("Failed to generate backup log file", err);
-        } finally {
-            // Store logs
-            writeFileAsync(this._fileFullPath, data);
-        }
-    }
-
-    private async _fileCleanupTask(): Promise<void> {
-        try {
-            let files = await readdirAsync(this._tempDir);
-            // Filter only backup files
-            files = files.filter((f) => path.basename(f).indexOf(this._backUpNameFormat) > -1);
-            // Sort by creation date
-            files.sort((a: string, b: string) => {
-                // Check expiration
-                const aCreationDate: Date = new Date(parseInt(a.split(this._backUpNameFormat)[0]));
-                const bCreationDate: Date = new Date(parseInt(b.split(this._backUpNameFormat)[0]));
-                if (aCreationDate < bCreationDate) {
-                    return -1;
-                }
-                if (aCreationDate >= bCreationDate) {
-                    return 1;
-                }
-            });
-            const totalFiles = files.length;
-            for (let i = 0; i < totalFiles - this._maxHistory; i++) {
-                const pathToDelete = path.join(this._tempDir, files[i]);
-                await unlinkAsync(pathToDelete);
-            }
-        } catch (err) {
-            // eslint-disable-next-line no-console
-            console.log(this._TAG, `Failed to cleanup log files: ${err && err.message}`);
-        }
-    }
-}
diff --git a/src/shared/logging/logger.ts b/src/shared/logging/logger.ts
deleted file mode 100644
index 87eb06b..0000000
--- a/src/shared/logging/logger.ts
+++ /dev/null
@@ -1,92 +0,0 @@
-import { diag, DiagLogger, DiagLogLevel } from "@opentelemetry/api";
-import { InternalAzureLogger } from "./internalAzureLogger";
-
-export class Logger implements DiagLogger {
-    private static _instance: Logger;
-
-    private _TAG = "ApplicationInsights:";
-    private _diagLevel: DiagLogLevel;
-    private _internalLogger: InternalAzureLogger;
-
-    static getInstance() {
-        if (!Logger._instance) {
-            Logger._instance = new Logger();
-        }
-        return Logger._instance;
-    }
-
-    constructor() {
-        this._internalLogger = new InternalAzureLogger();
-        const envLogLevel = process.env.APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL;
-        this._diagLevel = DiagLogLevel.WARN; // Default
-        switch (envLogLevel) {
-            case "ALL":
-                this._diagLevel = DiagLogLevel.ALL;
-                break;
-            case "DEBUG":
-                this._diagLevel = DiagLogLevel.DEBUG;
-                break;
-            case "ERROR":
-                this._diagLevel = DiagLogLevel.ERROR;
-                break;
-            case "INFO":
-                this._diagLevel = DiagLogLevel.INFO;
-                break;
-            case "NONE":
-                this._diagLevel = DiagLogLevel.NONE;
-                break;
-            case "VERBOSE":
-                this._diagLevel = DiagLogLevel.VERBOSE;
-                break;
-            case "WARN":
-                this._diagLevel = DiagLogLevel.WARN;
-                break;
-        }
-        this.updateLogLevel(this._diagLevel);
-    }
-
-    /**
-     * Set the global LogLevel. If a global diag logger is already set, this will override it.
-     * @param logLevel - The DiagLogLevel used to filter logs sent to the logger.
-     * @param suppressOverrideMessage - Setting that suppress the warning message normally emitted when registering a logger when another logger is already registered.
-     */
-    public updateLogLevel(logLevel: DiagLogLevel, suppressOverrideMessage = true) {
-        this._diagLevel = logLevel;
-
-        // Set OpenTelemetry Logger
-        diag.setLogger(this, {
-            logLevel: this._diagLevel,
-            suppressOverrideMessage,
-        });
-    }
-
-    public error(message?: any, ...optionalParams: any[]) {
-        if (this._diagLevel >= DiagLogLevel.ERROR) {
-            this._internalLogger.logMessage(this._TAG + message, optionalParams);
-        }
-    }
-
-    public warn(message?: any, ...optionalParams: any[]) {
-        if (this._diagLevel >= DiagLogLevel.WARN) {
-            this._internalLogger.logMessage(this._TAG + message, optionalParams);
-        }
-    }
-
-    public info(message?: any, ...optionalParams: any[]) {
-        if (this._diagLevel >= DiagLogLevel.INFO) {
-            this._internalLogger.logMessage(this._TAG + message, optionalParams);
-        }
-    }
-
-    public debug(message?: any, ...optionalParams: any[]) {
-        if (this._diagLevel >= DiagLogLevel.DEBUG) {
-            this._internalLogger.logMessage(this._TAG + message, optionalParams);
-        }
-    }
-
-    public verbose(message?: any, ...optionalParams: any[]) {
-        if (this._diagLevel >= DiagLogLevel.VERBOSE) {
-            this._internalLogger.logMessage(this._TAG + message, optionalParams);
-        }
-    }
-}
diff --git a/src/shared/util/util.ts b/src/shared/util/util.ts
index f764aaa..b1e6758 100644
--- a/src/shared/util/util.ts
+++ b/src/shared/util/util.ts
@@ -1,4 +1,8 @@
-﻿import { Logger } from "../logging";
+﻿// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT license.
+
+import { diag } from "@opentelemetry/api";
+
 
 export class Util {
     private static _instance: Util;
@@ -102,7 +106,7 @@ export class Util {
     }
 
     /**
-     * Returns string representation of an object suitable for diagnostics Logger.getInstance().
+     * Returns string representation of an object suitable for diagnostics diag.
      */
     public dumpObj(object: any): string {
         const objectTypeDump: string = Object["prototype"].toString.call(object);
@@ -120,7 +124,7 @@ export class Util {
         try {
             return JSON.stringify(payload);
         } catch (error) {
-            Logger.getInstance().warn("Failed to serialize payload", error, payload);
+            diag.warn("Failed to serialize payload", error, payload);
         }
     }
 
diff --git a/src/shim/applicationinsights.ts b/src/shim/applicationinsights.ts
index 5f71ef4..1bcf6eb 100644
--- a/src/shim/applicationinsights.ts
+++ b/src/shim/applicationinsights.ts
@@ -1,12 +1,14 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT license.
+
 import * as http from "http";
 import * as azureFunctionsTypes from "@azure/functions";
-import { SpanContext } from "@opentelemetry/api";
+import { SpanContext, diag } from "@opentelemetry/api";
 import { Span } from "@opentelemetry/sdk-trace-base";
 import { CorrelationContextManager } from "./correlationContextManager";
 import { ICorrelationContext, HttpRequest, DistributedTracingModes } from "./types";
 import { TelemetryClient } from "./telemetryClient";
 import * as Contracts from "../declarations/contracts";
-import { Logger } from "../shared/logging";
 
 
 // We export these imports so that SDK users may use these classes directly.
@@ -47,7 +49,7 @@ export function start() {
         defaultClient.initialize();
         return Configuration;
     } catch (error) {
-        Logger.getInstance().warn("The default client has not been initialized. Please make sure to call setup() before start().");
+        diag.warn("The default client has not been initialized. Please make sure to call setup() before start().");
     }
 }
 
diff --git a/src/shim/correlationContextManager.ts b/src/shim/correlationContextManager.ts
index ab79d61..7171164 100644
--- a/src/shim/correlationContextManager.ts
+++ b/src/shim/correlationContextManager.ts
@@ -1,13 +1,16 @@
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT license.
+
 import * as events from "events";
 import * as http from "http";
-import { context, SpanContext, trace, Context } from "@opentelemetry/api";
+import * as azureFunctionsTypes from "@azure/functions";
+import { context, SpanContext, trace, Context, diag } from "@opentelemetry/api";
 import { TraceState } from "@opentelemetry/core";
 import { Span } from "@opentelemetry/sdk-trace-base";
 import { ICorrelationContext, ITraceparent, ITracestate, HttpRequest, ICustomProperties } from "./types";
-import { Logger } from "../shared/logging";
-import * as azureFunctionsTypes from "@azure/functions";
 import { Util } from "../shared/util";
 
+
 const CONTEXT_NAME = "ApplicationInsights-Context";
 
 export class CorrelationContextManager {
@@ -109,7 +112,7 @@ export class CorrelationContextManager {
             const newContext: Context = trace.setSpanContext(context.active(), this._contextObjectToSpanContext(ctx));
             return context.with(newContext, fn);
         } catch (error) {
-            Logger.getInstance().warn("Error binding to session context", Util.getInstance().dumpObj(error));
+            diag.warn("Error binding to session context", Util.getInstance().dumpObj(error));
         }
         return fn();
     }
@@ -122,7 +125,7 @@ export class CorrelationContextManager {
         try {
             context.bind(context.active(), emitter);
         } catch (error) {
-            Logger.getInstance().warn("Error binding to session context", Util.getInstance().dumpObj(error));
+            diag.warn("Error binding to session context", Util.getInstance().dumpObj(error));
         }
     }
     
@@ -146,7 +149,7 @@ export class CorrelationContextManager {
             // If no context is passed, bind to the current context
             return context.bind(context.active(), fn);
         } catch (error) {
-            Logger.getInstance().error("Error binding to session context", Util.getInstance().dumpObj(error));
+            diag.error("Error binding to session context", Util.getInstance().dumpObj(error));
             return fn;
         }
     }
@@ -157,7 +160,7 @@ export class CorrelationContextManager {
      */
     // eslint-disable-next-line @typescript-eslint/no-unused-vars
     public static enable(forceClsHooked?: boolean) {
-        Logger.getInstance().info("Enabling the context manager is no longer necessary and this method is a no-op.");
+        diag.info("Enabling the context manager is no longer necessary and this method is a no-op.");
     }
 
     /**
@@ -241,7 +244,7 @@ export class CorrelationContextManager {
                 tracestateObj
             );
         }
-        Logger.getInstance().warn("startOperation was called with invalid arguments");
+        diag.warn("startOperation was called with invalid arguments");
         return null;
     }
 
@@ -249,7 +252,7 @@ export class CorrelationContextManager {
      * Disables the CorrelationContextManager
      */
     public static disable() {
-        Logger.getInstance().warn("It will not be possible to re-enable the current context manager after disabling it!");
+        diag.warn("It will not be possible to re-enable the current context manager after disabling it!");
         this._isDisabled = true;
         context.disable();
     }
@@ -258,7 +261,7 @@ export class CorrelationContextManager {
      * Resets the namespace
      */
     public static reset() {
-        Logger.getInstance().info("This is a no-op and exists only for compatibility reasons.");
+        diag.info("This is a no-op and exists only for compatibility reasons.");
     }
 
     /**
diff --git a/src/shim/nodeClient.ts b/src/shim/nodeClient.ts
index 0acf0e0..684fa7b 100644
--- a/src/shim/nodeClient.ts
+++ b/src/shim/nodeClient.ts
@@ -1,4 +1,7 @@
-import { Logger } from "../shared/logging";
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT license.
+
+import { diag } from "@opentelemetry/api";
 import { Contracts, TelemetryClient } from "./applicationinsights";
 
 class NodeClient extends TelemetryClient {
@@ -9,7 +12,7 @@ class NodeClient extends TelemetryClient {
      * @param telemetry Object encapsulating incoming request, response and duration information
      */
     public trackNodeHttpRequestSync(telemetry: Contracts.NodeHttpRequestTelemetry) {
-        Logger.getInstance().warn("trackNodeHttpRequestSync is not implemented and is a no-op.");
+        diag.warn("trackNodeHttpRequestSync is not implemented and is a no-op.");
     }
     
     /**
@@ -18,7 +21,7 @@ class NodeClient extends TelemetryClient {
      * @param telemetry Object encapsulating incoming request and response information
      */
     public trackNodeHttpRequest(telemetry: Contracts.NodeHttpRequestTelemetry) {
-        Logger.getInstance().warn("trackNodeHttpRequest is not implemented and is a no-op.");
+        diag.warn("trackNodeHttpRequest is not implemented and is a no-op.");
     }
     
     /**
@@ -27,7 +30,7 @@ class NodeClient extends TelemetryClient {
      * @param telemetry Object encapsulating outgoing request information
      */
     public trackNodeHttpDependency(telemetry: Contracts.NodeHttpRequestTelemetry) {
-        Logger.getInstance().warn("trackNodeHttpDependency is not implemented and is a no-op.");
+        diag.warn("trackNodeHttpDependency is not implemented and is a no-op.");
     }
 }
 
diff --git a/src/shim/shim-config.ts b/src/shim/shim-config.ts
index 7756c7e..e3f5664 100644
--- a/src/shim/shim-config.ts
+++ b/src/shim/shim-config.ts
@@ -3,10 +3,9 @@
 import http = require("http");
 import https = require("https");
 import azureCoreAuth = require("@azure/core-auth");
-import { DiagLogLevel } from "@opentelemetry/api";
+import { DiagLogLevel, diag } from "@opentelemetry/api";
 import { HttpInstrumentationConfig } from "@opentelemetry/instrumentation-http";
 import { DistributedTracingModes, IConfig, IDisabledExtendedMetrics, IWebInstrumentationConfig } from "./types";
-import { Logger } from "../shared/logging";
 import { ShimJsonConfig } from "./shim-jsonConfig";
 import { AzureMonitorOpenTelemetryOptions, ExtendedMetricType, InstrumentationOptionsType } from "../types";
 
@@ -219,7 +218,7 @@ class Config implements IConfig {
                 };
             }
             catch (err) {
-                Logger.getInstance().warn("failed to parse proxy URL.");
+                diag.warn("failed to parse proxy URL.");
             }
         }
         if (this.maxBatchIntervalMs) {
@@ -228,13 +227,23 @@ class Config implements IConfig {
             options.otlpLogExporterConfig = { ...options.otlpLogExporterConfig, timeoutMillis: this.maxBatchIntervalMs };
         }
         if (this.enableInternalWarningLogging === true) {
-            Logger.getInstance().updateLogLevel(DiagLogLevel.WARN);
+            // Do not override env variable if present
+            if (!process.env["APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL"]) {
+                process.env["APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL"] = "WARN";
+            }
+
         }
         if (this.enableInternalDebugLogging === true) {
-            Logger.getInstance().updateLogLevel(DiagLogLevel.DEBUG);
+            // Do not override env variable if present
+            if (!process.env["APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL"]) {
+                process.env["APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL"] = "DEBUG";
+            }
         }
         if (this.enableAutoCollectPreAggregatedMetrics === false) {
-            process.env["APPLICATION_INSIGHTS_NO_STANDARD_METRICS"] = "disable";
+            // Do not override env variable if present
+            if (!process.env["APPLICATION_INSIGHTS_NO_STANDARD_METRICS"]) {
+                process.env["APPLICATION_INSIGHTS_NO_STANDARD_METRICS"] = "disable";
+            }
         }
         // NATIVE METRICS
         if (typeof (this.enableAutoCollectExtendedMetrics) === "boolean") {
@@ -318,49 +327,49 @@ class Config implements IConfig {
 
         // NOT SUPPORTED CONFIGURATION OPTIONS
         if (this.disableAppInsights) {
-            Logger.getInstance().warn("disableAppInsights configuration no longer supported.");
+            diag.warn("disableAppInsights configuration no longer supported.");
         }
         if (this.enableAutoCollectHeartbeat) {
-            Logger.getInstance().warn("Heartbeat metris are no longer supported.");
+            diag.warn("Heartbeat metris are no longer supported.");
         }
         if (this.enableAutoDependencyCorrelation === false) {
-            Logger.getInstance().warn("Auto dependency correlation cannot be turned off anymore.");
+            diag.warn("Auto dependency correlation cannot be turned off anymore.");
         }
         if (typeof (this.enableAutoCollectIncomingRequestAzureFunctions) === "boolean") {
-            Logger.getInstance().warn("Auto request generation in Azure Functions is no longer supported.");
+            diag.warn("Auto request generation in Azure Functions is no longer supported.");
         }
         if (typeof (this.enableSendLiveMetrics) === "boolean") {
-            Logger.getInstance().warn("Live Metrics is currently not supported.");
+            diag.warn("Live Metrics is currently not supported.");
         }
         if (this.enableUseAsyncHooks === false) {
-            Logger.getInstance().warn("The use of non async hooks is no longer supported.");
+            diag.warn("The use of non async hooks is no longer supported.");
         }
         if (this.distributedTracingMode === DistributedTracingModes.AI) {
-            Logger.getInstance().warn("AI only distributed tracing mode is no longer supported.");
+            diag.warn("AI only distributed tracing mode is no longer supported.");
         }
         if (this.enableResendInterval) {
-            Logger.getInstance().warn("The resendInterval configuration option is not supported by the shim.");
+            diag.warn("The resendInterval configuration option is not supported by the shim.");
         }
         if (this.enableMaxBytesOnDisk) {
-            Logger.getInstance().warn("The maxBytesOnDisk configuration option is not supported by the shim.");
+            diag.warn("The maxBytesOnDisk configuration option is not supported by the shim.");
         }
         if (this.ignoreLegacyHeaders === false) {
-            Logger.getInstance().warn("LegacyHeaders are not supported by the shim.");
+            diag.warn("LegacyHeaders are not supported by the shim.");
         }
 
         if (this.maxBatchSize) {
-            Logger.getInstance().warn("The maxBatchSize configuration option is not supported by the shim.");
+            diag.warn("The maxBatchSize configuration option is not supported by the shim.");
         }
         if (this.enableLoggerErrorToTrace) {
-            Logger.getInstance().warn("The enableLoggerErrorToTrace configuration option is not supported by the shim.");
+            diag.warn("The enableLoggerErrorToTrace configuration option is not supported by the shim.");
         }
         if (this.httpAgent || this.httpsAgent) {
-            Logger.getInstance().warn("The httpAgent and httpsAgent configuration options are not supported by the shim.");
+            diag.warn("The httpAgent and httpsAgent configuration options are not supported by the shim.");
         }
         if (
             this.enableWebInstrumentation || this.webInstrumentationConfig || this.webInstrumentationSrc || this.webInstrumentationConnectionString
         ) {
-            Logger.getInstance().warn("The webInstrumentation configuration options are not supported by the shim.");
+            diag.warn("The webInstrumentation configuration options are not supported by the shim.");
         }
         return options;
     }
diff --git a/src/shim/shim-jsonConfig.ts b/src/shim/shim-jsonConfig.ts
index 5573d3b..5fadceb 100644
--- a/src/shim/shim-jsonConfig.ts
+++ b/src/shim/shim-jsonConfig.ts
@@ -1,10 +1,10 @@
 import * as fs from "fs";
 import * as path from "path";
-import { Logger } from "../shared/logging/logger";
-import { DistributedTracingModes, IDisabledExtendedMetrics, IJsonConfig, IWebInstrumentationConfig } from "./types";
 import * as http from "http";
 import * as https from "https";
 import * as azureCoreAuth from "@azure/core-auth";
+import { DistributedTracingModes, IDisabledExtendedMetrics, IJsonConfig, IWebInstrumentationConfig } from "./types";
+import { diag } from "@opentelemetry/api";
 
 const ENV_CONFIGURATION_FILE = "APPLICATIONINSIGHTS_CONFIGURATION_FILE";
 const ENV_CONTENT = "APPLICATIONINSIGHTS_CONFIGURATION_CONTENT";
@@ -114,7 +114,7 @@ export class ShimJsonConfig implements IJsonConfig {
             try {
                 jsonString = fs.readFileSync(tempDir, "utf8");
             } catch (err) {
-                Logger.getInstance().info("Failed to read JSON config file: ", err);
+                diag.info("Failed to read JSON config file: ", err);
             }
         }
         try {
@@ -182,7 +182,7 @@ export class ShimJsonConfig implements IJsonConfig {
             this.webInstrumentationConfig = jsonConfig.webInstrumentationConfig;
             this.quickPulseHost = jsonConfig.quickPulseHost;
         } catch (err) {
-            Logger.getInstance().info("Missing or invalid JSON config file: ", err);
+            diag.info("Missing or invalid JSON config file: ", err);
         }
     }
 }
\ No newline at end of file
diff --git a/src/shim/telemetryClient.ts b/src/shim/telemetryClient.ts
index 922b900..58a5960 100644
--- a/src/shim/telemetryClient.ts
+++ b/src/shim/telemetryClient.ts
@@ -1,14 +1,13 @@
 // Copyright (c) Microsoft Corporation.
 // Licensed under the MIT license.
 
-import { Attributes, context, metrics, ProxyTracerProvider, SpanKind, SpanOptions, SpanStatusCode, trace } from "@opentelemetry/api";
+import { Attributes, context, metrics, ProxyTracerProvider, SpanKind, SpanOptions, SpanStatusCode, diag, trace } from "@opentelemetry/api";
 import { logs } from "@opentelemetry/api-logs";
 import { LoggerProvider } from "@opentelemetry/sdk-logs";
 import { SemanticAttributes } from "@opentelemetry/semantic-conventions";
 import * as Contracts from "../declarations/contracts";
 import { TelemetryItem as Envelope } from "../declarations/generated";
 import { Context } from "./context";
-import { Logger } from "../shared/logging";
 import { Util } from "../shared/util";
 import Config = require("./shim-config");
 import { AttributeSpanProcessor } from "../shared/util/attributeSpanProcessor";
@@ -127,7 +126,7 @@ export class TelemetryClient {
         // Create custom metric
         const meter = metrics.getMeterProvider().getMeter("ApplicationInsightsMetrics");
         const histogram = meter.createHistogram(telemetry.name);
-        histogram.record(telemetry.value, {...telemetry.properties, ...this.commonProperties, ...this.context.tags });
+        histogram.record(telemetry.value, { ...telemetry.properties, ...this.commonProperties, ...this.context.tags });
     }
 
     /**
@@ -185,7 +184,7 @@ export class TelemetryClient {
             } catch (error) {
                 // set target as null to be compliant with previous behavior
                 telemetry.target = null;
-                Logger.getInstance().warn(this.constructor.name, "Failed to create URL.", error);
+                diag.warn(this.constructor.name, "Failed to create URL.", error);
             }
         }
         const ctx = context.active();
@@ -243,8 +242,8 @@ export class TelemetryClient {
      * Get Authorization handler
      */
     public getAuthorizationHandler(config: Config): void {
-        Logger.getInstance().warn("getAuthorizationHandler is not supported in ApplicationInsights any longer.");
-    } 
+        diag.warn("getAuthorizationHandler is not supported in ApplicationInsights any longer.");
+    }
 
     /*
      * Get Statsbeat instance
@@ -273,7 +272,7 @@ export class TelemetryClient {
             contextObjects?: { [name: string]: any }
         ) => boolean
     ) {
-        Logger.getInstance().warn("addTelemetryProcessor is not supported in ApplicationInsights any longer.");
+        diag.warn("addTelemetryProcessor is not supported in ApplicationInsights any longer.");
     }
 
     /*
@@ -284,15 +283,15 @@ export class TelemetryClient {
     }
 
     public trackNodeHttpRequestSync(telemetry: Contracts.NodeHttpRequestTelemetry) {
-        Logger.getInstance().warn("trackNodeHttpRequestSync is not implemented and is a no-op. Please use trackRequest instead.");
+        diag.warn("trackNodeHttpRequestSync is not implemented and is a no-op. Please use trackRequest instead.");
     }
 
     public trackNodeHttpRequest(telemetry: Contracts.NodeHttpRequestTelemetry) {
-        Logger.getInstance().warn("trackNodeHttpRequest is not implemented and is a no-op. Please use trackRequest instead.");
+        diag.warn("trackNodeHttpRequest is not implemented and is a no-op. Please use trackRequest instead.");
     }
 
     public trackNodeHttpDependency(telemetry: Contracts.NodeHttpRequestTelemetry) {
-        Logger.getInstance().warn("trackNodeHttpDependency is not implemented and is a no-op. Please use trackDependency instead.");
+        diag.warn("trackNodeHttpDependency is not implemented and is a no-op. Please use trackDependency instead.");
     }
 
     /**


Test patch:
diff --git a/test/unitTests/shared/internalAzureLogger.tests.ts b/test/unitTests/shared/internalAzureLogger.tests.ts
deleted file mode 100644
index dc616fe..0000000
--- a/test/unitTests/shared/internalAzureLogger.tests.ts
+++ /dev/null
@@ -1,180 +0,0 @@
-// Copyright (c) Microsoft Corporation.
-// Licensed under the MIT license.
-
-import * as assert from "assert";
-import * as sinon from "sinon";
-
-import { InternalAzureLogger } from "../../../src/shared/logging/internalAzureLogger";
-import * as fileHelper from "../../../src/shared/util/fileSystemHelper";
-
-describe("Library/InternalAzureLogger", () => {
-  let sandbox: sinon.SinonSandbox;
-  let originalEnv: NodeJS.ProcessEnv;
-  let internalLogger: InternalAzureLogger;
-
-  before(() => {
-    sandbox = sinon.createSandbox();
-  });
-
-  beforeEach(() => {
-    originalEnv = process.env;
-    internalLogger = new InternalAzureLogger();
-  });
-
-  afterEach(() => {
-    process.env = originalEnv;
-    sandbox.restore();
-    (internalLogger as any) = null;
-  });
-
-  describe("Write to file", () => {
-    it("should log message to new file", (done) => {
-      const confirmDirStub = sandbox.stub(fileHelper, "confirmDirExists").callsFake(async () => {
-        // Fake directory creation
-      });
-      const appendFileAsyncStub = sandbox.stub(fileHelper, "appendFileAsync");
-      internalLogger["_logToFile"] = true;
-
-      internalLogger
-        .logMessage("testMessage")
-        .then(() => {
-          assert.ok(confirmDirStub.called, "confirmDirStub called");
-          assert.ok(appendFileAsyncStub.called, "writeStub called"); // File creation was called
-          assert.ok(
-            appendFileAsyncStub.lastCall.args[0].toString().indexOf("applicationinsights.log") > 0
-          );
-          assert.equal(appendFileAsyncStub.lastCall.args[1], "testMessage\r\n");
-          done();
-        })
-        .catch((error: Error) => {
-          done(error);
-        });
-    });
-
-    it("should create backup file", (done) => {
-      sandbox.stub(fileHelper, "confirmDirExists").callsFake(async () => {});
-      sandbox.stub(fileHelper, "accessAsync").callsFake(async () => {});
-      sandbox.stub(fileHelper, "getShallowFileSize").callsFake(
-        async () =>
-          // Fake file size check
-          123
-      );
-      internalLogger["_maxSizeBytes"] = 122;
-
-      const writeStub = sandbox.stub(fileHelper, "writeFileAsync");
-      const appendStub = sandbox.stub(fileHelper, "appendFileAsync");
-      const readStub = sandbox.stub(fileHelper, "readFileAsync");
-      internalLogger["_logToFile"] = true;
-
-      internalLogger
-        .logMessage("backupTestMessage")
-        .then(() => {
-          assert.ok(readStub.calledOnce, "readStub calledOnce"); // Read content to create backup
-          assert.ok(appendStub.notCalled, "appendStub notCalled");
-          assert.ok(writeStub.calledTwice, "writeStub calledTwice");
-          assert.ok(
-            writeStub.args[0][0].toString().indexOf(".applicationinsights.log") > 0,
-            ".applicationinsights.log present in backup file name"
-          ); // First call is for backup file
-          assert.equal(writeStub.args[1][1], "backupTestMessage\r\n");
-          done();
-        })
-        .catch((error: Error) => {
-          done(error);
-        });
-    });
-
-    it("should create multiple backup files", (done) => {
-      sandbox.stub(fileHelper, "confirmDirExists").callsFake(async () => {});
-      sandbox.stub(fileHelper, "accessAsync").callsFake(async () => {});
-      sandbox.stub(fileHelper, "getShallowFileSize").callsFake(
-        async () =>
-          // Fake file size check
-          123
-      );
-      const writeStub = sandbox.stub(fileHelper, "writeFileAsync");
-      const readStub = sandbox.stub(fileHelper, "readFileAsync");
-      internalLogger["_maxSizeBytes"] = 122;
-      internalLogger["_logToFile"] = true;
-      internalLogger
-        .logMessage("backupTestMessage")
-        .then(() => {
-          internalLogger
-            .logMessage("backupTestMessage")
-            .then(() => {
-              assert.equal(writeStub.callCount, 4);
-              assert.ok(readStub.calledTwice);
-              done();
-            })
-            .catch((error: Error) => {
-              done(error);
-            });
-        })
-
-        .catch((error: Error) => {
-          done(error);
-        });
-    });
-
-    it("should start file cleanup task", () => {
-      (internalLogger as any) = null;
-      const env = <{ [id: string]: string }>{};
-      env["APPLICATIONINSIGHTS_LOG_DESTINATION"] = "file";
-      process.env = env;
-      const setIntervalSpy = sandbox.spy(global, "setInterval");
-      internalLogger = new InternalAzureLogger();
-      assert.ok(setIntervalSpy.called);
-      assert.ok(internalLogger["_fileCleanupTimer"]);
-    });
-
-    it("should remove backup files", (done) => {
-      sandbox
-        .stub(fileHelper, "readdirAsync")
-        .callsFake(
-          async () =>
-            [
-              "applicationinsights.log",
-              "123.applicationinsights.log",
-              "456.applicationinsights.log",
-            ] as any
-        );
-      internalLogger["_maxHistory"] = 0;
-      const unlinkStub = sandbox.stub(fileHelper, "unlinkAsync");
-      internalLogger["_fileCleanupTask"]()
-        .then(() => {
-          assert.ok(unlinkStub.calledTwice, "unlinkStub calledTwice");
-          done();
-        })
-        .catch((error: Error) => {
-          done(error);
-        });
-    });
-
-    it("cleanup should keep configured number of backups", (done) => {
-      sandbox
-        .stub(fileHelper, "readdirAsync")
-        .callsFake(
-          async () =>
-            [
-              "applicationinsights.log",
-              "123.applicationinsights.log",
-              "456.applicationinsights.log",
-            ] as any
-        );
-      internalLogger["_maxHistory"] = 1;
-      const unlinkStub = sandbox.stub(fileHelper, "unlinkAsync");
-      internalLogger["_fileCleanupTask"]()
-        .then(() => {
-          assert.ok(unlinkStub.calledOnce, "unlinkStub calledOnce");
-          assert.ok(
-            unlinkStub.args[0][0].toString().indexOf("123.applicationinsights.log") > 0,
-            "Oldest file is deleted"
-          );
-          done();
-        })
-        .catch((error: Error) => {
-          done(error);
-        });
-    });
-  });
-});
diff --git a/test/unitTests/shared/logging.tests.ts b/test/unitTests/shared/logging.tests.ts
deleted file mode 100644
index a93cbbc..0000000
--- a/test/unitTests/shared/logging.tests.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-import { diag, DiagLogLevel } from "@opentelemetry/api";
-import * as assert from "assert";
-import * as sinon from "sinon";
-
-import { Logger } from "../../../src/shared/logging";
-
-describe("Library/Logger", () => {
-    let sandbox: sinon.SinonSandbox;
-    let stub: sinon.SinonStub;
-
-    before(() => {
-        sandbox = sinon.createSandbox();
-        stub = sandbox.stub(Logger.getInstance()["_internalLogger"], "logMessage");
-    });
-
-    afterEach(() => {
-        sandbox.restore();
-    });
-
-    describe("constructor", () => {
-        it("should enable OpenTelemetry logging", () => {
-            Logger.getInstance().updateLogLevel(DiagLogLevel.INFO);
-            diag.info("Test"); // OpenTelemetry global logger
-            assert.ok(stub.called);
-        });
-    });
-
-    describe("logMessage", () => {
-        it("should log info message", () => {
-            Logger.getInstance().updateLogLevel(DiagLogLevel.INFO);
-            Logger.getInstance().info("test");
-            assert.ok(stub.called);
-        });
-
-        it("should log debug message", () => {
-            Logger.getInstance().updateLogLevel(DiagLogLevel.DEBUG);
-            Logger.getInstance().debug("test");
-            assert.ok(stub.called);
-        });
-
-        it("should log error message", () => {
-            Logger.getInstance().updateLogLevel(DiagLogLevel.ERROR);
-            Logger.getInstance().error("test");
-            assert.ok(stub.called);
-        });
-
-        it("should log verbose message", () => {
-            Logger.getInstance().updateLogLevel(DiagLogLevel.VERBOSE);
-            Logger.getInstance().verbose("test");
-            assert.ok(stub.called);
-        });
-
-        it("should log warn message", () => {
-            Logger.getInstance().updateLogLevel(DiagLogLevel.WARN);
-            Logger.getInstance().warn("test");
-            assert.ok(stub.called);
-        });
-    });
-});
diff --git a/test/unitTests/shim/applicationInsights.tests.ts b/test/unitTests/shim/applicationInsights.tests.ts
index f81fe8e..ad8f516 100644
--- a/test/unitTests/shim/applicationInsights.tests.ts
+++ b/test/unitTests/shim/applicationInsights.tests.ts
@@ -4,8 +4,7 @@ import * as assert from "assert";
 import * as sinon from "sinon";
 
 import * as appInsights from "../../../src/index";
-import { Logger } from "../../../src/shared/logging";
-import { DiagLogLevel } from "@opentelemetry/api";
+import { diag, DiagLogLevel } from "@opentelemetry/api";
 
 describe("ApplicationInsights", () => {
     let sandbox: sinon.SinonSandbox;
@@ -137,7 +136,7 @@ describe("ApplicationInsights", () => {
                 appInsights.setup(connString);
                 appInsights.Configuration.setInternalLogging(true, false);
                 appInsights.start();
-                assert.equal(Logger.getInstance()["_diagLevel"], DiagLogLevel.DEBUG);
+                assert.equal(process.env["APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL"], "DEBUG");
             });
 
             it("should warn if attempting to auto collect incoming azure functions requests", () => {
diff --git a/test/unitTests/shim/config.tests.ts b/test/unitTests/shim/config.tests.ts
index b0dbc11..6c6a6b0 100644
--- a/test/unitTests/shim/config.tests.ts
+++ b/test/unitTests/shim/config.tests.ts
@@ -5,7 +5,6 @@ import sinon = require('sinon');
 import azureCoreAuth = require("@azure/core-auth");
 import { DiagLogLevel } from '@opentelemetry/api';
 import { HttpInstrumentationConfig } from '@opentelemetry/instrumentation-http';
-import { Logger } from "../../../src/shared/logging"
 import Config = require('../../../src/shim/shim-config');
 import { TelemetryClient } from "../../../src/shim/telemetryClient";
 import http = require("http");
@@ -97,17 +96,21 @@ describe("shim/configuration/config", () => {
         });
 
         it("should activate DEBUG internal logger", () => {
+            const env = <{ [id: string]: string }>{};
+            process.env = env;
             const config = new Config(connectionString);
             config.enableInternalDebugLogging = true;
             config.parseConfig();
-            assert.equal(Logger.getInstance()["_diagLevel"], DiagLogLevel.DEBUG);
+            assert.equal(process.env["APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL"], "DEBUG");
         });
 
         it("should activate WARN internal logger", () => {
+            const env = <{ [id: string]: string }>{};
+            process.env = env;
             const config = new Config(connectionString);
             config.enableInternalWarningLogging = true;
             config.parseConfig();
-            assert.equal(Logger.getInstance()["_diagLevel"], DiagLogLevel.WARN);
+            assert.equal(process.env["APPLICATIONINSIGHTS_INSTRUMENTATION_LOGGING_LEVEL"], "WARN");
         });
 
         it("should disableAllExtendedMetrics", () => {