I have the following NLog setup:
// Custom serializer for exceptions
LogManager.Setup().SetupSerialization(s =>
s.RegisterObjectTransformation<Exception>(ex => new {
Data = ex.ToBetterString()
})
);
// In the layout I configure the exception like this:
jsonLayout.Attributes.Add(new JsonAttribute("exception", "${exception:format=@}"));
So this gets my exception and parses the exception text in a more beautiful way, then put it in an anonymous object in a Data property. So this property is a multiline string.
When the log arrives at CloudWatch, I get the following result:
As you can see in the image, there are two problems:
- the property is being recognized as a string instead of an object
- the
\r\ncharacters are not being parsed as newline characters
Is there any way to properly see this in CloudWatch?
---------------- UPDATE -----------------
As pointed by @Stefan adding encode = false helped a little bit. Now the exception property is recognized as json, just the multiline string is not being rendered properly:


