本站不再更新,歡迎光臨 java開(kāi)發(fā)技術(shù)網(wǎng)
          隨筆-230  評(píng)論-230  文章-8  trackbacks-0

          package com.ff.utils;

          import java.util.Date;

          import net.rim.device.api.system.EventLogger;

          /**
           * 日志類
           * @author   2010-09-04
           *
           */
          public class Logger {

           private static final String SEPARATOR = "   ";
           private static final long GUID = 0x4c9d3452d880a2f1L;
           private static final String APP_NAME = "xxxc ";

           private Logger() {
            EventLogger.register(GUID, APP_NAME, EventLogger.VIEWER_STRING);
           }

           private static Logger logger = new Logger();

           public static Logger getLogger() {
            return logger;
           }

           /**
            * Log the information.
            *
            * @param message
            *            The message you will log
            */
           public void info(String message) {
            if (message == null || message.trim().equals(""))
             return;
            String log = "INFO: " + new Date().toString() + SEPARATOR + message;
            try {
             log = new String(log.getBytes(), "UTF-8");
             byte[] msg_bytes = log.getBytes();
             EventLogger.logEvent(GUID, msg_bytes, EventLogger.ALWAYS_LOG);
            } catch (Exception ex) {
             System.err.println(ex);
            }
           }

           public void error(Exception e) {
            StringBuffer log = new StringBuffer();
            log.append("ERROR: " + new Date().toString() + SEPARATOR);
            log.append(e.getMessage() + " \r\n ");

            try {
             byte[] msg_bytes = new String(log.toString().getBytes(), "UTF-8").getBytes();
             EventLogger.logEvent(GUID, msg_bytes);
            } catch (Exception ex) {
             System.err.println(ex);
            }
           }
           
           public void error(String message, Exception e) {
            StringBuffer log = new StringBuffer();
            log.append("ERROR: " + new Date().toString() + SEPARATOR);
            if (message != null || !message.trim().equals("")) {
             log.append("message: " + message + " \r\n ");
            }
            log.append("error: " + e.getMessage() + " \r\n ");

            try {
             byte[] msg_bytes = new String(log.toString().getBytes(), "UTF-8").getBytes();
             EventLogger.logEvent(GUID, msg_bytes);
            } catch (Exception ex) {
             System.err.println(ex);
            }
           }
          }


          不管是在模擬器還是真機(jī),日志還是必須的......如果該文對(duì)你有用,為了表示對(duì)作者的支持,麻煩你單擊一下下面的廣告,謝謝

          posted on 2010-09-05 16:55 有貓相伴的日子 閱讀(601) 評(píng)論(0)  編輯  收藏 所屬分類: blackberry

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          本站不再更新,歡迎光臨 java開(kāi)發(fā)技術(shù)網(wǎng)
          主站蜘蛛池模板: 阿尔山市| 阿瓦提县| 亳州市| 鹤峰县| 北安市| 东乡县| 亚东县| 蕲春县| 迁安市| 高雄县| 镇安县| 依安县| 乡宁县| 博罗县| 陆丰市| 巴东县| 芜湖市| 故城县| 神农架林区| 兴业县| 沙洋县| 华坪县| 东方市| 眉山市| 册亨县| 普宁市| 林甸县| 娄烦县| 丁青县| 招远市| 灌南县| 云龙县| 同江市| 鄯善县| 怀化市| 茶陵县| 广丰县| 郑州市| 化州市| 永顺县| 元阳县|