简体   繁体   English

Java脚本未将日志写入文件,而是在控制台上显示日志

[英]Java script is not writing the logs into file but showing the logs on console

I am trying to create a logfile where I want to write everything info/error/warn etc. 我正在尝试创建一个日志文件,我想在其中写所有信息/错误/警告等。

Below is my code where I can see the logs on console but the script is not writing into a file: 以下是我的代码,在其中可以看到控制台上的日志,但脚本未写入文件:

 var log4js = require('log4js'); log4js.configure({ appenders: { cleanupLogs: { type: 'file', filename: 'QuoteCleanup.log' }, console: { type: 'console' } }, categories: { default: { appenders: ['console'], level: 'trace' } } }); var log = log4js.getLogger(); 

You can use this devtools snippet shown below to create a console.save method. 您可以使用下面显示的devtools片段创建console.save方法。 It creates a FileBlob from the input, and then automatically downloads it. 它从输入中创建一个FileBlob,然后自动下载它。

Edited I just edited my answer try this one and tell if this works for you 编辑我刚刚编辑了答案,请尝试这个答案,并告诉它是否对您有用

 log4js.configure({ appenders: { everything: { type: 'file', filename: 'QuoteCleanup.log' } }, categories: { default: { appenders: ['everything'], level: 'debug' } } }); const logger = log4js.getLogger(); logger.debug('I will be logged in QuoteCleanup.log'); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM