使用日誌類RFileLogger輸出除錯資訊

2021-04-17 21:00:34 字數 1338 閱讀 7479

一、概述:

類rfilelogger對應的標頭檔案和庫檔案分別是flogger.h和flogger.lib。

我習慣把opening**放到我希望跟蹤的class的constructl()函式裡面,然後在析構函式裡closing.在真正編碼時,你最好檢測一下connect和createlog是否返回了kerrnone.

二、使用:

1、在類的二階段構造constructl()中加上下面**:

//開啟日誌檔案服務的連線

rfilelogger ilog; ilog.connect(); ilog.createlog(_l("myloggingdirectory"),_l("mylogfile"),efileloggingmodeoverwrite)

上面**,是我的log檔案的full path(手機上的檔案系統) c:/logs/myloggingdirectory/mylogfile.

2、在類的析構函式中加入下面**:

//關閉log檔案和伺服器連線

ilog.closelog();

ilog.close();

3、向日誌檔案中輸入文字和資料

命令                                    log檔案

ilog.write(_l("hello world"))                       11/07/2003 4:00:13 hello world

ilog.writeformat(_l("result=%d"),err)             11/07/2003 4:00:13 result=0 ilog.hexdump(aheader,aheader,myptr,4)        11/07/2003 4:00:13 mybuf:0000: 41 42 00 44 ab.d

如果不想記錄日期和事件,可以使用這個函式來關閉:

ilog.setdateandtime(tbool ausedate, tbool ausetime)

三、使用注意:

1、  在模擬器上除錯時(即日誌檔案檔案建立在計算機上):

這時,日誌檔案的目錄應該是:c:/symbian/7.0s/series60_v21/epoc32/wins/c/logs

上面的**實際上就是在這個目錄裡建立乙個名字為myloggingdirectory的資料夾,並在這裡面建立乙個沒有副檔名的日誌檔案mylogfile。

注意:資料夾myloggingdirectory必須由我們手動建立,但日誌檔案mylogfile程式會給我們建立。如果沒有建立這個資料夾,那麼日誌檔案也就不會被建立了,但這時候程式也不會報錯,只是得不到除錯資訊了而已。

2、  在手機上除錯時(即日誌檔案建立在手機上):

Log日誌類的開發和使用

2 新建乙個類,如下 import org.apache.commons.logging.log import org.apache.commons.logging.logfactory public class chinese public void eat public void walk de...

日誌幫助類

從網上找了些資源,借鑑整理之後,自己隨便寫了乙個。public class loghelper loghelper private static loghelper loghelper private static readonly object sysroot new object 日誌類的單一實...

C 通用類 日誌記錄類

using system using system.collections.generic using system.io using system.linq using system.text using system.threading.tasks using system.web namesp...