Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure eclipse osgi log

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 ..
like image 646
Sanmoy Avatar asked Sep 26 '11 03:09

Sanmoy


People also ask

How to configure Logback in OSGi environment?

Usually Logback is configured by a logback.xml or logback-test.xml file. (see Logback configuration manual) In an OSGi environment it is not that easy for Logback to automatically determine where the logback.xml logger configuration is stored.

How to get the default logger in Eclipse?

By default Eclipse logs all messages. In case dependency injection is not available in the class where logging is requested, the logger can be obtained by using the service API: 2. SLF4J in eclipse applications Many Java developers are more familiar with the SLF4J logging facade, which is more powerful than Eclipse’s default logger. 2.1.

How do I get the console logs in Eclipse?

open the “console” view. select the “host osgi console.” start org.eclipse.equinox.cm start org.ops4j.pax.logging.pax-logging-api start org.ops4j.pax.logging.pax-logging-service start org.ops4j.pax.configmanager now you should be able to see your log statements in the configured “example.log” file.

How to get all log messages in Eclipse?

The value can be set to INFO, WARNING and ERROR, INFO will for example show all log message. By default Eclipse logs all messages. In case dependency injection is not available in the class where logging is requested, the logger can be obtained by using the service API:


1 Answers

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

like image 148
Dmytro Pishchukhin Avatar answered Oct 12 '22 21:10

Dmytro Pishchukhin