Hi Libor,

Yes, I am aware of the option for getting a system property in an OSGi bundle. Well, in the system, there may be other bundles (which I'm not aware of/responsible) consuming Derby and they may have their own configurations for logging. Even I may have two different components using different schemas. For instance,
are two schemas which are completely disjoint and used by different components. That's way I wanted to have different logging configurations for different components/bundles.

I think the solution lies in a system-wide, common logging class which is aware of the source class calling the logging method. So, it can direct the log to corresponding OutputStreams.


On 07/13/2012 12:53 AM, Libor Jelinek wrote:
Hello there,
I also don't consider myself as a OSGi super expert but just having some experience in OSGi-fying other apps for Eclipse Equinox and it's sometimes challenging.

Why is bad to by driven by system property? Consider you have bundle A that is depending on (consuming) Derby bundle, then consumer bundle should contribute a system property by normal Java means like System.setProperty().

Or in case of Equinox it's even easier as you can set system property for JVM (actually Equinox launcher) declarative in product definition XML.

More over, I'm curious about your setup because Derby bundle should be installed just and only once at most in one running OSGi environment (framework).


On Thu, Jul 12, 2012 at 4:59 PM, Rick Hillegas <rick.hillegas@oracle.com> wrote:
On 7/12/12 6:26 AM, Suat Gonul wrote:
On 07/12/2012 03:54 PM, Rick Hillegas wrote:
On 7/12/12 5:22 AM, Suat Gonul wrote:
Hi everybody,

In an OSGi based environment we are using the Derby database. So, I
would like to adjust location and the names of the derby.log file.
However, adjusting the global system properties e.g "derby.system.home",
"derby.stream.error.file" is not an option for us as there might be
other bundles using the Derby.

In our system, we use Sling Logging Tools [1]. Is there any way to
integrate those tools with the logging mechanism of Derby. Or is there
any other way to configure the location and name of the "derby.log"
file? Thanks in advance...


[1] http://sling.apache.org/site/logging.html

Hi Suat,

If you can wrap your custom logger in a class which implements
java.io.OutputStream or java.io.Writer, then you can configure Derby
to use that class. Please see the Reference Manual section on setting
the derby.stream.error.method system property:

Hope this helps,

Thanks for the fast reply. Then the only way to configure logging is to
adjust some system properties. Is there a way so that one OSGi component
uses "method1" while the other uses "method2" for logging. I am asking
this, because those components use completely different schemas.


Hi Suat,

The method would have to figure out what component it is running in. I'm not an expert on how OSGi works but it is likely that each component runs in its own Classloader. What if the method was in a class loaded by the same Classloader which loaded the Derby instance? Could  you map Classloaders to components and then map components to the configuration information you need to pick the right log file? What if the Sling Logging Tools were loaded, per component, by the same Classloader which loaded the Derby instance? Sorry to be waving my hands here.

I may not be understanding your problem. It sounds as though you have multiple Derby instances and you want each instance to log error messages to a separate file.

Hope this helps and doesn't just muddle the problem,