public void RemoveEmptyLogEntries()
        {
            using (var stream = new MemoryStream(File.ReadAllBytes(@"data\SitecoreLog4.txt")))
            {
                var sitecoreLogParser = new SitecoreLogParser();
                var uri = new Uri("http://localhost/data/SitecoreLog1.log.20160606.172133.txt");

                var result = sitecoreLogParser.Parse(() => stream, uri, new DiagnosticsSourceSummary()).ToList();
                Assert.NotNull(result);
                Assert.Equal(result.Count, 1);
                var parsedLog = result.Last();
                Assert.NotNull(parsedLog);
                Assert.Equal(parsedLog[SitecoreLogParser.SitecoreLogFields.Level], "INFO");
                Assert.Equal(parsedLog[SitecoreLogParser.SitecoreLogFields.Message], "Sitecore started");
            }
        }
Пример #2
0
        public void ParseCompleteErrorLevel()
        {
            using (var stream = new MemoryStream(File.ReadAllBytes(@"data\SitecoreLog3.txt")))
            {
                var sitecoreLogParser = new SitecoreLogParser();
                var uri = new Uri("http://localhost/data/sitecoredev228CA/xyz/asosbaselogfile.20160101.180755.txt");

                var result = sitecoreLogParser.Parse(stream, uri).ToList();
                Assert.NotNull(result);
                var parsedLog = result.FirstOrDefault();
                Assert.NotNull(parsedLog);
                Assert.Equal(parsedLog.Properties[SitecoreLogParser.SitecoreLogFields.Level].StringValue, "ERROR");
                Assert.True(parsedLog.Properties[SitecoreLogParser.SitecoreLogFields.Message].StringValue.StartsWith("Test Error with exception\r\n"));
                Assert.True(parsedLog.Properties[SitecoreLogParser.SitecoreLogFields.Message].StringValue.EndsWith("Parameter name: database"));
                Assert.True(result.Count() == 2);
            }
        }
Пример #3
0
        public void ParseSingleInfoLevel()
        {
            using (var stream = new MemoryStream(File.ReadAllBytes(@"data\SitecoreLog1.txt")))
            {
                var sitecoreLogParser = new SitecoreLogParser();
                var uri = new Uri("http://localhost/data/SitecoreLog1.log.20160613.172129.txt");

                var result = sitecoreLogParser.Parse(stream, uri);
                Assert.NotNull(result);
                var parsedLog = result.FirstOrDefault();
                Assert.NotNull(parsedLog);
                Assert.Equal(parsedLog.Properties[SitecoreLogParser.SitecoreLogFields.ProcessId].StringValue, "ManagedPoolThread #0");
                Assert.Equal(parsedLog.Properties[SitecoreLogParser.SitecoreLogFields.Level].StringValue, "INFO");
                Assert.Equal(parsedLog.Timestamp, DateTimeOffset.Parse("2016-06-13 17:12:32"));
                Assert.Equal(parsedLog.Properties[SitecoreLogParser.SitecoreLogFields.Message].StringValue, "Trying to load XML configuration /App_Config/Security/GlobalRoles.config");
            }
        }
        public void ParseSingleInfoLevel()
        {
            using (var stream = new MemoryStream(File.ReadAllBytes(@"data\SitecoreLog1.txt")))
            {
                var sitecoreLogParser = new SitecoreLogParser();
                var uri = new Uri("http://localhost/data/SitecoreLog1.log.20160613.172129.txt");

                var result = sitecoreLogParser.Parse(() => stream, uri, new DiagnosticsSourceSummary());
                Assert.NotNull(result);
                var parsedLog = result.FirstOrDefault();
                Assert.NotNull(parsedLog);
                Assert.Equal(parsedLog[SitecoreLogParser.SitecoreLogFields.ProcessId], "ManagedPoolThread #0");
                Assert.Equal(parsedLog[SitecoreLogParser.SitecoreLogFields.Level], "INFO");
                Assert.Equal(parsedLog["@timestamp"], "2016-06-13T17:12:32");
                Assert.Equal(parsedLog[SitecoreLogParser.SitecoreLogFields.Message], "Trying to load XML configuration /App_Config/Security/GlobalRoles.config");
            }
        }
Пример #5
0
        public void ParseMultipleLogs()
        {
            using (var stream = new MemoryStream(File.ReadAllBytes(@"data\SitecoreDetailedLog.txt")))
            {
                var sitecoreLogParser = new SitecoreLogParser();
                var uri = new Uri("http://localhost/data/SitecoreLog1.log.20160606.172133.txt");

                var result = sitecoreLogParser.Parse(stream, uri).ToList();
                Assert.NotNull(result);
                Assert.Equal(result.Count, 57);
                var parsedLog = result.Last();
                Assert.NotNull(parsedLog);
                Assert.Equal(parsedLog.Properties[SitecoreLogParser.SitecoreLogFields.Level].StringValue, "WARN");
                Assert.Equal(parsedLog.Properties[SitecoreLogParser.SitecoreLogFields.Message].StringValue, "Shutdown message: HostingEnvironment initiated shutdown");

                foreach (var log in result)
                {
                    Assert.NotNull(log);
                    Assert.NotEqual(log.Properties[SitecoreLogParser.SitecoreLogFields.Message].StringValue, string.Empty);
                    Assert.False(log.Properties[SitecoreLogParser.SitecoreLogFields.Message].StringValue.Contains("****"));
                }
            }
        }