I am having an issue with JSNlog and Nlog with formatting Exceptions coming from JSNlog. I am writing all my error logs out as JSON but when I throw an exception from javascript the system is encoding the %message property as JSON as well causing the outer JSON to be invalid.
My configuration for the Nlog.config file for this appender is:
layout='{"Enviroment":"${aspnet-application:variable=Enviroment}","CreatedOn": "${longdate:universalTime=true}", "WindowsIdentity":"${aspnet-user-identity:jsonEncode=true}","Application":"${AppName}", "Level":"${level}", ${message}}' />
My configuration for the web.config for JSNlog is:
serverSideMessageFormat=""UserAgent": "%userAgent", "SessionId": "%requestId", "URL":"%url", "UserAddress": "%userHostAddress", "Message": "%message""
When I run with this configuration it works for all normal fatal/error/warn/info/debug/trace calls but it fails with invalid JSON on any fatalException calls with the following JSON:
{"Enviroment":"Dev", "CreatedOn": "2014-09-24 23:58:42.1734", "WindowsIdentity":"XXXr","Application":"LoggingTest", "Level":"Fatal", "UserAgent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36", "SessionId": "befn1iy4mlxqowppwepf104z", "URL":"/LoggingTest/jsnlog.logger", "UserAddress": "10.247.224.202", "Message": "{"stack":"TypeError: undefined is not a function\n at Log (http://zue-v-86a32393.vpc-am.aws.shell-cloud.com/LoggingTest/:58:16)\n at HTMLInputElement.onclick (http:/XXXX/LoggingTest/:66:141)","message":"undefined is not a function","name":"TypeError","logData":"JS Fatal Exception"}"}
I have tried removing the quotes around the message and it then works fine for fatalException calls but fails to be valid JSON for any other logging calls as it is missing the quotes.
Does anyone know how to remedy this problem or format the exception coming out of the fatalException call?