CloudWatchAppender icon indicating copy to clipboard operation
CloudWatchAppender copied to clipboard

Cloud watch with log4net API

Open princykv opened this issue 7 years ago • 3 comments

Hi,

I am trying to integrate log4net API to push all application logs directly to Cloud watch. This is working fine. But message in json format is truncated. I am trying to log API request and response content. My API is using following JSON format for request/response.

{ "Name": "SyncAPI", "Message": { "LastSyncNo": 100 }, "Status": { "Success": false, "Code": 422 } }

Following layout pattern is used in log4net configuration. Could you please help me to log data in above mentioned JSON format using log4net?

<layout type="AWSAppender.Core.Layout.PatternLayout, AWSAppender.Core"> <conversionPattern value="%date [%thread] %-5level %message" /> </layout> Regards, Princy

princykv avatar May 04 '17 07:05 princykv

Hi!

Sorry for the late response.

The LogsAppender will attempt to parse the json, and in doing so recognizes certain keywords, among them Message. This is where it expects the main message to be.

The parser is not particularly good so it get's confused reading the above.

It should be possible to escape the json as in for example

{Message:\"{\"Name\": \"SyncAPI\",\"Message\": {\"LastSyncNo\": 100},\"Status\": {\"Success\": false,\"Code\": 422}}}\""

Sadly, this does not work, so this is a proper bug.

The work around in the meantime is to replace Message with Message_ or some such.

camitz avatar Jul 21 '17 13:07 camitz

Ok, Thanks for the information.

princykv avatar Aug 09 '17 13:08 princykv

Hi I would like work on the above issue and contribute my solution to the problem .Please provide me with the necessary requirements so that I will start working on it. Since it is mandatory for my course requirement I assure you for the completion of the issue.

mnss8991 avatar Apr 04 '21 19:04 mnss8991