I have a question regarding writing logs in an AngularJS project. Which logging method should I use to write logs to a file? Should I use Angular's $log or log4javascript? I currently have the following code configuration for using Angular's $log:
$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);
};
}
While this setup successfully writes logs to the console, I now want to modify it so that the logs are written to a file instead. How can I achieve this?