我正在使用 https://pub.dartlang.org/packages/logging ,但它不会在我的日志中显示任何内容。这是我的代码:
class Test {
final Logger log = new Logger('testLogger');
Future<String> join() async {
try {
return await func();
} on Exception catch (e) {
log.severe('access denied!');
return null;
}
}
最佳答案
您需要注册一个日志报告器。
来自 https://pub.dartlang.org/packages/logging
main() {
Logger.root.level = Level.ALL;
Logger.root.onRecord.listen((LogRecord rec) {
debugPrint('${rec.level.name}: ${rec.time}: ${rec.message}');
});
runApp(...);
}
您可以让日志报告器写入文件或某些日志服务器,...
关于logging - flutter :记录器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54628459/