我正在为一个BlackBerry应用程序实现日志记录,以跟踪我的应用程序的流程。BlackBerry开发人员使用什么机制来实现这一点?
发布于 2010-10-29 20:04:53
从一开始,EventLogger就是一个值得尊敬的应用程序接口。您可以通过按住alt键并按下'L‘'G’'L‘'G’来查看设备上的日志
发布于 2010-11-05 15:30:29
内置EventLogger的一个困难是没有编程方法来读出它。出于这个原因,我实现了自己的记录器,并包含了远程诊断功能。
发布于 2011-03-15 03:33:29
我建议你实现自己的日志记录类,因为它提供了很大的灵活性,例如
1)您可以让类将输出发送到多个位置,以便在使用调试器时可以更快地访问日志,例如
/**
* Internal function to encapsulate event logging
*
* @param msg - message to log
* @param level - log level to use, e.g. EventLogger.DEBUG_INFO,
* INFORMATION, WARNING, ERROR, SEVERE_ERROR
*/
private void makeLog(String msg, int level)
{
// You can also manipulate logs here, e.g.
// -add the Class and/or Application name
// -truncate or remove repeat logs, etc
// Log to phone event log
EventLogger.logEvent(ID, msg.getBytes(), level);
// In the debugger log to the console
System.err.println(msg);
} 2)为方便起见,您可以添加具有可读名称的方法,这些方法记录在不同的严重性级别,例如
public void debug(String msg)
{
makeLog(msg, EventLogger.DEBUG_INFO);
}然后,您可以调用MyLogClass.debug("debug message")或MyLogClass.warning("warning message"),这将使您更加清楚日志的重要性。
https://stackoverflow.com/questions/4050685
复制相似问题