有没有办法替换Android中的标准Log? [英] Is there a way to replace the standard Log in Android?

查看:209
本文介绍了有没有办法替换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.

这篇关于有没有办法替换Android中的标准Log?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆