有没有办法替换Android中的标准Log?
是否可以通过某种方式拦截对标准登录android的调用并执行其他操作?
Is there a way to somehow intercept calls to the standard Log in android and perform some other action?
在桌面Java中,通常会获得一些记录器,因此可以通过多种方法来安装不同的记录处理程序/实现.但是,Android似乎对Log进行了静态调用,而且我找不到有关替换默认行为的任何信息.
In desktop Java one would usually get some logger so there are ways to install a different logging handler / implementation. However, Android seems to have a static call to Log, and I could not find any information about replacing the default behavior.
我意识到我可以通过ADB监视设备日志,但是我希望在选择加入设备的设备上运行应用程序时有不同的行为(例如,通过在程序启动时执行特定指令).
I realize I can monitor the device log through ADB, but I'd like to have a different behavior in running apps on a device who opt in (e.g., by executing a certain instruction when the program starts out).
AedonEtLIRA指出Log是最终版本,因此您需要滚动/借用新的.我一直在使用Prasanta Paul的"MLog": http: //prasanta-paul.blogspot.com/2010/07/custom-logger-for-android.html
As AedonEtLIRA points out Log is final so you need to roll/borrow a new one. I've been using Prasanta Paul's "MLog": http://prasanta-paul.blogspot.com/2010/07/custom-logger-for-android.html
通过它可以轻松地将日志保存到文本文件和/或完全禁用日志记录. 如果它还不能满足您的需求,那么它是管理日志记录的良好基础.
It makes it easy to save logs to a text file and/or disable logging completely. If it doesn't already do what you need, it is a good base for managing logging.