首页 > 解决方案 > Flutter Android 日志过多且冗长

问题描述

当我在 Android 模拟器上运行应用程序时,或者在物理设备上运行应用程序时,日志是巨大的,而且常常是压倒性的……我想知道如何只获取相关的输出,而不是像这样的不必要的日志:

W/om.tejas.pethu( 7618): Accessing hidden method Ljava/security/spec/ECParameterSpec;->getCurveName()Ljava/lang/String; (greylist, reflection, allowed)
I/ProviderInstaller( 7618): Installed default security provider GmsCore_OpenSSL
W/om.tejas.pethu( 7618): Accessing hidden field Ljava/net/Socket;->impl:Ljava/net/SocketImpl; (greylist, reflection, allowed)
W/om.tejas.pethu( 7618): Accessing hidden method Ldalvik/system/CloseGuard;->get()Ldalvik/system/CloseGuard; (greylist,core-platform-api, linking, allowed)
W/om.tejas.pethu( 7618): Accessing hidden method Ldalvik/system/CloseGuard;->open(Ljava/lang/String;)V (greylist,core-platform-api, linking, allowed)
W/om.tejas.pethu( 7618): Accessing hidden field Ljava/io/FileDescriptor;->descriptor:I (greylist, JNI, allowed)
W/om.tejas.pethu( 7618): Accessing hidden method Ljava/security/spec/ECParameterSpec;->setCurveName(Ljava/lang/String;)V (greylist, reflection, allowed)
W/om.tejas.pethu( 7618): Accessing hidden method Ldalvik/system/BlockGuard;->getThreadPolicy()Ldalvik/system/BlockGuard$Policy; (greylist,core-platform-api, linking, allowed)
W/om.tejas.pethu( 7618): Accessing hidden method Ldalvik/system/BlockGuard$Policy;->onNetwork()V (greylist, linking, allowed)

请记住,在运行时会产生大量的详细日志......这使得很难找到哪些日志是冗长和不必要的,以及您希望看到的日志是什么样的print('Hello');

请注意,在像上面这样的详细日志中查找这个Hello字符串至少可以说是具有挑战性的。

这与干净且不冗长的 iOS 日志相比:

Launching lib/main.dart on iPhone 11 Pro Max in debug mode...
Xcode build done.                                           33.6s
Configuring the default Firebase app...
Configured the default Firebase app __FIRAPP_DEFAULT.
Connecting to VM Service at ws://127.0.0.1:54149/6CwtGLU6Ci0=/ws

值得注意的是,在运行时,只显示重要的日志/必要的日志,如 Dart 编译器错误和print语句。

我要问的是:

  1. 有没有办法过滤这些日志,以便我只得到 Dart/Flutter 编译器产生的打印语句和错误?

  2. 如果不可能,有没有办法以非黑客的方式停止这些日志?我不想进入任何在幕后为我们编写的复杂源代码......

flutter run -d <device-id>如果不超过上述值,则产生相同的多余日志:

An Observatory debugger and profiler on sdk gphone x86 arm is available at:
http://127.0.0.1:55302/9hN29j0-dRE=/
W/DynamiteModule( 7842): Local module descriptor class for providerinstaller not found.
I/DynamiteModule( 7842): Considering local module providerinstaller:0 and remote module providerinstaller:0
W/ProviderInstaller( 7842): Failed to load providerinstaller module: No acceptable module found. Local version is 0 and remote version is 0.
I/TetheringManager( 7842): registerTetheringEventCallback:com.tejas.pethub
I/om.tejas.pethu( 7842): The ClassLoaderContext is a special shared library.
I/om.tejas.pethu( 7842): Waiting for a blocking GC ProfileSaver
I/om.tejas.pethu( 7842): The ClassLoaderContext is a special shared library.
I/om.tejas.pethu( 7842): The ClassLoaderContext is a special shared library.
V/NativeCrypto( 7842): Registering com/google/android/gms/org/conscrypt/NativeCrypto's 286 native methods...
W/om.tejas.pethu( 7842): Accessing hidden method Ljava/security/spec/ECParameterSpec;->getCurveName()Ljava/lang/String; (greylist, reflection, allowed)
I/ProviderInstaller( 7842): Installed default security provider GmsCore_OpenSSL
W/om.tejas.pethu( 7842): Accessing hidden field Ljava/net/Socket;->impl:Ljava/net/SocketImpl; (greylist, reflection, allowed)
W/om.tejas.pethu( 7842): Accessing hidden method Ldalvik/system/CloseGuard;->get()Ldalvik/system/CloseGuard; (greylist,core-platform-api, linking, allowed)
W/om.tejas.pethu( 7842): Accessing hidden method Ldalvik/system/CloseGuard;->open(Ljava/lang/String;)V (greylist,core-platform-api, linking, allowed)
W/om.tejas.pethu( 7842): Accessing hidden field Ljava/io/FileDescriptor;->descriptor:I (greylist, JNI, allowed)
W/om.tejas.pethu( 7842): Accessing hidden method Ljava/security/spec/ECParameterSpec;->setCurveName(Ljava/lang/String;)V (greylist, reflection, allowed)
W/om.tejas.pethu( 7842): Accessing hidden method Ldalvik/system/BlockGuard;->getThreadPolicy()Ldalvik/system/BlockGuard$Policy; (greylist,core-platform-api, linking, allowed)
W/om.tejas.pethu( 7842): Accessing hidden method Ldalvik/system/BlockGuard$Policy;->onNetwork()V (greylist, linking, allowed)

感谢您为我提供的任何帮助,我很感激!

标签: androidiosflutterdart

解决方案


推荐阅读