public void SetUp() { Message = @" This is a message !""£$%^&* With lots of possibly bad things in it"; // all the control chars Message += '\u0001'; Message += '\u0002'; Message += '\u0003'; Message += '\u0004'; Message += '\u0005'; Message += '\u0006'; Message += '\u0007'; Message += '\u0008'; Message += '\u0009'; Message += '\u0010'; Message += '\u0011'; Message += '\u0012'; Message += '\u0013'; Message += '\u0014'; Message += '\u0015'; Message += '\u0016'; Message += '\u0017'; Message += '\u0018'; Message += '\u0019'; LogEvent = new LogEventInfo { Exception = new Exception("Outer Exception", new Exception("Inner Exception")), Level = LogLevel.Error, LoggerName = "ExampleLoggerName", Message = Message, Parameters = new object[] { "One", 1234 }, Properties = { { "PropertyOne", "one" }, { "PropertyTwo", 2 } }, TimeStamp = new DateTime(2014, 1, 2, 3, 4, 5, 623, DateTimeKind.Utc) }; Renderer = new StructuredLoggingLayoutRenderer(); Result = Renderer.Render(LogEvent); var outFileDir = "C:\\Temp"; Directory.CreateDirectory(outFileDir); File.WriteAllLines(Path.Combine(outFileDir, "out.txt"), new[] { Result }); }
public void SetUp() { LogEvent = new LogEventInfo { Exception = new Exception(), Level = LogLevel.Error, LoggerName = "ExampleLoggerName", Message = "test message", TimeStamp = new DateTime(2014, 1, 2, 3, 4, 5, 623, DateTimeKind.Utc) }; ThisNameWillAppearInTheCallSite(LogEvent); Renderer = new StructuredLoggingLayoutRenderer(); Result = Renderer.Render(LogEvent); }
public void JustSayingMessagesSerializeFine() { var layoutRenderer = new StructuredLoggingLayoutRenderer(); var logProperties = new FulfilmentStatusChangedNotificationRequested("some-order-id", "delivering", "thai-rice", "", "07839474638", 123, 234, 345); var log = new LogEventInfo(LogLevel.Info, "TheLoggerName", "Received message"); var propertyDictionary = logProperties.GetType().GetProperties().ToDictionary(x => x.Name, x => x.GetValue(logProperties, null)); foreach (var element in propertyDictionary) { log.Properties.Add(element.Key, element.Value); } var result = layoutRenderer.Render(log); Assert.That(result, Is.Not.Empty); }