使用工具为HBuilder,编程语言为javascript
console.log("this is a log");
console.info("this is an info");
console.warn("this is a warn");
console.error('this is an error');在控制台得到的结果为
"this is a log"
"this is an info"
"this is a warn"
"this is an error"
使用cmd得到相同的结果。
日志的重定向:>(尖括号重定向)
尖括号重定向是对log()和info()的输出,在log.txt文件中是这样的
this is a log
this is an info重定向符号 1> 和 2>
在login.txt中是
this is a log
this is an info
在err.txt中是
this is a warn
this is an error1> 相当于>
2>是将error()和warn()输出
本文介绍了如何使用HBuilder编辑器和JavaScript语言在控制台中输出不同类型的日志信息,并详细解释了日志重定向功能,包括如何将输出保存到文本文件中。
902

被折叠的 条评论
为什么被折叠?



