public void Log_DisabledIfPlaceholder() { string message = "TestMessage"; string functionInvocationId = Guid.NewGuid().ToString(); string activityId = Guid.NewGuid().ToString(); _environment.SetEnvironmentVariable(EnvironmentSettingNames.AzureWebsitePlaceholderMode, "1"); _logger.LogInformation(message); Assert.False(_logger.IsEnabled(LogLevel.Information)); _mockEventGenerator.Verify(m => m.LogAzureMonitorDiagnosticLogEvent(It.IsAny <LogLevel>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Never); }
public void Log_DisabledIfNoSiteName() { string message = "TestMessage"; string functionInvocationId = Guid.NewGuid().ToString(); string activityId = Guid.NewGuid().ToString(); _environment.SetEnvironmentVariable(EnvironmentSettingNames.AzureWebsiteHostName, null); // Recreate the logger was we cache the site name in the constructor ILogger logger = new AzureMonitorDiagnosticLogger(_category, _hostInstanceId, _mockEventGenerator.Object, _environment, new LoggerExternalScopeProvider(), _hostNameProvider); logger.LogInformation(message); Assert.False(logger.IsEnabled(LogLevel.Information)); _mockEventGenerator.Verify(m => m.LogAzureMonitorDiagnosticLogEvent(It.IsAny <LogLevel>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Never); }