I am trying to use log4javascript's ajaxAppender to send a batch of messages to the server in my app.
This is how I initialized logging:
var log = log4javascript.getDefaultLogger();
log.info('Logging initialized');
var ajaxAppender = new log4javascript.AjaxAppender("http://localhost:8080/mobile2/logger/logme.json");
ajaxAppender.addHeader("Content-Type","application/json;charset=utf-8");
ajaxAppender.setBatchSize(10);
var jsonLayout = new log4javascript.JsonLayout(false,true);
ajaxAppender.setLayout(jsonLayout);
log.info(jsonLayout.getContentType());
log.addAppender(ajaxAppender);
I am using spring on the server and its @RequestBody tag to read in the json object.
This works for my other server requests but when using the ajaxAppender it always fails with this error; SEVERE: Servlet.service() for servlet spring threw exception java.lang.IllegalArgumentException: Invalid token character ',' in token "x-www-form-urlencoded, application/json"
The only difference I can see is that when I inspect the request headers, the headers for logging have a content type of the following: Content-Type: application/x-www-form-urlencoded, application/json;charset=UTF-8
whereas my other json requests only have the second string 'application/json;charset=UTF-8'
Is it possible to send the ajax without the first content type? Not sure what else to try.
Thanks