private static void Log404()
        {
            var logger = new ApplicationInsightsLogger("main-webpage", new TelemetryClient(), new ApplicationInsightsLoggerOptions()
            {
                IncludeScopes = false
            });

            logger.LogWarning(new EventId(2, "Request hit a 404"), "Request hit a 404");
        }
Exemplo n.º 2
0
        public void TestLoggerCreatesTraceTelemetryOnLoggedWarningWithParameters()
        {
            TelemetryClient client = CommonMocks.MockTelemetryClient((t) =>
            {
                Assert.IsType <TraceTelemetry>(t);
                var traceTelemetry = (TraceTelemetry)t;
                Assert.Equal("This is 123 value: Hello, World!", traceTelemetry.Message);
                Assert.Equal(SeverityLevel.Warning, traceTelemetry.SeverityLevel);
                Assert.Equal("test-category", traceTelemetry.Properties["CategoryName"]);

                Assert.Equal("123", traceTelemetry.Properties["testParam"]);
                Assert.Equal("Hello, World!", traceTelemetry.Properties["param2"]);
            });

            ILogger logger = new ApplicationInsightsLogger("test-category", client, (s, l) => { return(true); }, null);

            logger.LogWarning(0, "This is {testParam} value: {param2}", 123, "Hello, World!");
        }