9

I am using eclipse osgi jar. How to redirect the log generated by osgi to a file?

Whenever I start the osgi framework, it generates a log like 1317008078357.log. How to redirect this log to a custom file. Do I need to use log4j as a osgi bundle? what will be the log4j.xml configuration ?

log file contains:

!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 ..
Sanmoy
  • 589
  • 2
  • 9
  • 23

1 Answers1

8

Eclipse (Equinox) uses his own logger. To configure it you can define the logger options in config.ini:

  • osgi.logfile file name

  • eclipse.log.level sets the level used when logging messages to the eclipse log.

  • eclipse.log.backup.max the max number of backup log files to allow.

  • eclipse.log.size.max the max size in Kb that the log file is allowed to grow.

more details in Eclipse Help (http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/runtime-options.html)

also here: Logging in Eclipse/OSGi plugins and here: http://www.eclipsezone.com/eclipse/forums/t99588.html

Community
  • 1
  • 1
Dmytro Pishchukhin
  • 2,369
  • 1
  • 14
  • 19
  • Thanks for your reply. But "osgi.logfile" parameter doesn't exist in the page http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/runtime-options.html. It seems, eclipse wants to hide it !! Also, can you please tell how to give the log file a proper name, as we can assign the log file names with date in log4j. I don't want to put a static name. I have searched "osgi.logfile" in google for further details, but google also failed to find anything !! – Sanmoy Sep 26 '11 at 06:54
  • I use osgi.logfile in my current project. I use static name of file: e.g. -Dosgi.logfile=./config/equinox.log – Dmytro Pishchukhin Sep 26 '11 at 07:33
  • Note the number in the log file is the timestamp date (i.e. number of seconds since epoch). It's fairly easy to convert to a date afterwards if you want to. – AlBlue Sep 29 '11 at 08:59