Log4JavaScript server-side coding

286 Views Asked by At

I'm trying to use Log4Javascript for logging logs from JavaScript to a file. I'm using the AjaxAppender to try to send the data to the server. But whenever i am trying to log the file specified in url field is empty

url = "demo.log";
var ajaxAppender = new log4javascript.AjaxAppender(url);

As it is a POST request I can see in firebug that the data is sent as parameter. But how can the logs be saved in demo.log For each logger a new request is sent.

How can we append the logs in log file. I am new to Log4Javascript. Can anyone please help me on this. Thanks in advance.

1

There are 1 best solutions below

0
On

This question is rather old, but i want to give at least a short answer:

At first we take a look at the docs for the AjaxAppender of log4javascript:

A flexible appender that asynchronously sends log messages to a server via HTTP.

So, what you need is a server that is capable of handling your POST-Request. Whether you like to write a small server in JavaScript based on nodejs or a Java-Server or ... is your choice. But you need a server. And the server decides what to do with those messages, e.g. logging them to a file.

A possible JavaScript solution could be based on nodejs, express and log4js