我想更改 Karma(nee Testaulous)日志的格式。开箱即用,它看起来像这样:
INFO [karma]: Karma server started at http://localhost:8080/
文档说要查看 log4js 的其他记录器,默认为 [{type:'console'}]。因此,我首先将这些内容添加到我的 Karma 配置文件中:
loggers = [{ type: 'console'}]
并且惊喜地发现日志输出看起来像这样
[2013-05-29 11:23:55.807] [INFO] karma - Karma server started at http://localhost:8080/
已经到一半了。现在我想显示一条较短的消息。查看 log4j 后,我尝试了以下各项
loggers = [{ type: 'console', PatternLayout:'%d{HH:mm:ss} %m'}]
loggers = [{ type: 'console', ConversionPattern:'%d{HH:mm:ss} %m'}]
两者都没有改变结果。 log4j 文档说
The PatternLayout class extends the abstract org.apache.log4j.Layout class and overrides the format> () method to structure logging information according to a supplied pattern.
这只是 Karma 中没有实现还是我只是没有找到魔法关键字?
最佳答案
Karma 使用 log4js 。试试这个:
loggers: [{type: 'console', pattern: '%d{HH:mm:ss} %m'}]
关于testing - 如何配置 Karma 日志的格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16818768/