Menu

AjaxAppender + JsonLayout

Help
Anonymous
2012-07-23
2013-04-29
  • Anonymous

    Anonymous - 2012-07-23

    I set up log4javascript logger with the following code:

        var logger = log4javascript.getLogger();
        var appender = new log4javascript.AjaxAppender('some url");
        appender.setLayout(new log4javascript.JsonLayout(false, false));
        appender.setSendAllOnUnload(true); //default true
        appender.setThreshold(log4javascript.Level.ERROR);
        logger.addAppender(appender);
                       
        logger.error("test");
    

    however, the JSON sent seems encoded. This is what I can read from firebug or IE dev toolbar:

        data=%5B%7B%22logger%22%3A%22%5Banonymous%5D%22%2C%22timestamp%22%3A134303868
    

    Do you have any suggestions? (I'm using the latest production version)

     
  • Anonymous

    Anonymous - 2012-07-23

    How to FIX:

    1) write in JsonLayout class

         this.returnsPostData = true;
    

    2) remove the last 4 lines of code in PreparePostData to remove &layout=xx in the request body
    3) change the content-type in sendRequest to

        xmlHttp.setRequestHeader("Content-Type", appender.getLayout().getContentType());
    

    Do you notice something wrong with this patch?

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.