黑莓记录

时间:2010-10-29 09:40:46

标签: blackberry blackberry-simulator

我正在实施BlackBerry应用程序的日志记录以跟踪我的应用程序流。 BlackBerry开发人员使用哪些机制来执行此操作?

4 个答案:

答案 0 :(得分:3)

EventLogger是一个值得尊敬的API。您可以通过按住'alt'并点击'L''G''L''G'来查看设备上的日志

答案 1 :(得分:0)

内置的EventLogger的一个难点是没有编程方式来读取它。 出于这个原因,我实现了自己的记录器,并包括远程诊断功能。

答案 2 :(得分:0)

我建议您实现自己的日志记录类,因为它提供了很多灵活性,例如

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"),这样可以更清楚地了解日志的重要性。

答案 3 :(得分:0)

相关问题