Nguyễn Phúc Nguyễn Phúc - 6 months ago 239
Javascript Question

How to angularjs write log to file?

I have a question? In Angularjs project, what log I can use to write to file? $log of Angular or log4javascript.
I have code config for $log of Angularjs:

$log.getInstance = function (context) {
return {
log: enhanceLogging($log.log, context),
info: enhanceLogging($log.info, context),
warn: enhanceLogging($log.warn, context),
debug: enhanceLogging($log.debug, context),
error: enhanceLogging($log.error, context)
};
};

function enhanceLogging(loggingFunc, context) {
return function () {
var modifiedArguments = [].slice.call(arguments);
modifiedArguments[0] = [moment().format("dddd h:mm:ss a") + '::[' + context + ']: '] + modifiedArguments[0];
loggingFunc.apply(null, modifiedArguments);
};
}


It's working but it only write to console and now I want log output to file?

Answer

This link may help for logging into server side.

https://engineering.talis.com/articles/client-side-error-logging/
Comments