Encountering an issue with JSNlog and Nlog regarding the format of Exceptions from JSNlog. All error logs are being written out in JSON, but when an exception is thrown from JavaScript, the system encodes the %message property as JSON as well, causing the main JSON to become invalid.
The 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}}' />
The configuration for the web.config for JSNlog is:
serverSideMessageFormat=""UserAgent": "%userAgent", "SessionId": "%requestId", "URL":"%url", "UserAddress": "%userHostAddress", "Message": "%message""
With this configuration, it works fine for normal logging calls but fails on fatalException calls due to the resulting invalid JSON structure. For example:
{"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"}"}
Attempting to remove quotes around messages resolves the issue for fatalException calls but breaks JSON validity for other log types.
If anyone has a solution or suggestion on handling this problem with proper formatting of exceptions from fatalException calls, your insights would be greatly appreciated.