How to log to a file using log4javascript in javascript

216 views Asked by At

Best way to log into file using javascript. Thought of using log4javascript, but got examples only using node.js. Is there any way to do logging into a file using only javascript through log4javascript.

1

There are 1 answers

0
Soma Sarkar On

we can not directly write a file from client side. To log data into a file you need to take help of server side component. you can use ajaxappender to log data through server side component. Here is thecode snippet taken from "log4javascript.org". URL is a Http.POST method. Ajaxappender also solvesw CORS issue.

var ajaxAppender = new log4javascript.AjaxAppender(URL);
log.addAppender(ajaxAppender);