admin管理员组文章数量:1401919
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?
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?
Share Improve this question asked May 6, 2016 at 8:36 phuchoangmaiphuchoangmai 3051 gold badge6 silver badges15 bronze badges 1- If you want to log it into files, you have to send the logs to an API which will write the logs into files. – anotherdev Commented May 6, 2016 at 8:39
1 Answer
Reset to default 2Clientside Javascript does not have access to files on disk. So it is impossible to write to a logfile.
However you could use something like Sentry to log your messages.
本文标签: javascriptHow to angularjs write log to fileStack Overflow
版权声明:本文标题:javascript - How to angularjs write log to file? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744249567a2597184.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论