当我将以下代码添加到我的dart程序中时,我希望可以在天文台中进行一些登录,但是它是空的。
void setupLogging() {
Logger.root.level = Level.ALL;
Logger.root.onRecord.listen((LogRecord rec) {
print('${rec.level.name}: ${rec.time}: ${rec.message}');
});
}
然后以某种方法:
log.fine('Databases are up and running');
![observatory logging empty](https://i.sstatic.net/69YQv.jpg)
最佳答案
仅仅使用print
是行不通的,但是 dart:developer
库包含可用于该目的的 log
函数。
它具有与 LogRecord
软件包中的 logging
所使用的参数相同的参数:
void log(String message,
{DateTime time,
int sequenceNumber,
int level: 0,
String name: '',
Zone zone,
Object error,
StackTrace stackTrace});
关于dart - 天文台的记录箱为空,如何获取日志?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35002560/