2011-09-26 99 views
9

我正在使用eclipse osgi jar。 如何將由osgi生成的日誌重定向到文件配置eclipse osgi日誌

每當我啓動osgi框架,它會生成一個類似1317008078357.log的日誌。如何將此日誌重定向到custome文件。我需要使用log4j作爲osgi包嗎?什麼是log4j.xml配置?

日誌文件包含:

!SESSION 2011-09-26 11:34:38.232 ----------------------------------------------- 
eclipse.buildId=unknown 
java.version=1.6.0_26 
java.vendor=Sun Microsystems Inc. 
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US 
Command-line arguments: -configuration D:/CommonNBI/Trunck/release_structure/server/nbi/snmp/conf -console 
!ENTRY org.eclipse.osgi 2 0 2011-09-26 11:34:44.029 
!MESSAGE While loading class .... may not be fully initialized. 
!STACK 0 
org.osgi.framework.BundleException: State change in progress for bundle .. 

回答

7

的Eclipse(春分)用自己的記錄。要配置它,你可以在config.ini文件定義記錄器選項:

  • osgi.logfile 文件名

  • eclipse.log.level 將消息記錄到Eclipse日誌時使用的水平。

  • eclipse.log.backup.max 要允許的最大備份日誌文件數。

  • eclipse.log.size.max 允許日誌文件增長的以Kb爲單位的最大大小。

更多細節Eclipse幫助(http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/runtime-options.html

也在這裏:Logging in Eclipse/OSGi plugins 這裏:http://www.eclipsezone.com/eclipse/forums/t99588.html

+0

感謝您的答覆。但是,「osgi.logfile」參數在頁面中不存在http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/runtime-options html的。看來,月蝕想要隱藏它!另外,您可以告訴我們如何給日誌文件一個合適的名稱,因爲我們可以在log4j中爲日誌文件名分配日期。我不想放一個靜態名稱。我已經在谷歌搜索「osgi.logfile」進一步的細節,但谷歌也未能找到任何東西! – Sanmoy

+0

我在當前項目中使用osgi.logfile。我使用文件的靜態名稱:例如-Dosgi.logfile =。/ config/equinox.log –

+0

請注意,日誌文件中的數字是時間戳日期(即曆元以來的秒數)。如果你願意,可以很容易地轉換成日期。 – AlBlue