ekkehard at gentz-software.de
Mon Oct 20 14:38:50 CEST 2008
Ceki Gulcu schrieb:
> ekkehard wrote:
>> Ceki Gulcu schrieb:
>>> Hello Ekke,
>>> What is it that you are trying to accomplish, in plain English?
>> My Logger objects are in each class
>> but I also want to know the OSGI Bundle name from where the log entry comes
>> and - optional - the OSGI Service names from where the event happened
> What is the relation between bundles and services? For example, is it true to
> say that at time t0, bundle b0 offers services s00, s01, s02, bundle b1 offers
> services s10 and s11, while at a later time t1, bundle b0 offers services s00
> and bundle b1 offers services s10, s11 and s12?
> If the above is true, you could create a marker named B0, S00, S01, S02, B1, S10
> and S11. For example, with the following code
> Marker B0 = MarkerFactory.getMarker("B0");
> Marker B1 = MarkerFactory.getMarker("B1");
> Marker S00 = MarkerFactory.getMarker("S00");
> Marker S11 = MarkerFactory.getMarker("S11");
> Once the markers are created, you can organize them in a graph, for example as
> You can iterate through the references contained in a marker by calling the
> iterator() method. Thus, if you wish to print the name of a bundle and all the
> services it contains, you would print the name of the bundle marker and iterate
> through its service markers (and print their names).
> If at time t1 the list of services changes, then you can add or remove
> references to service markers from the bundler markers as appropriate.
> If you are using the default marker factory, keep in mind, in the two lines
> below, that x0 and x1 refer to the same marker object named X:
> Marker x0 = MarkerFactory.getMarker("X");
> marker x1 = MarkerFactory.getMarker("X");
> My point is that, the default marker factory cannot deal with the same bundle
> markers having two different facets simultaneously depending on the context.
> For example, you can't assume that the same bundles offers s0 for one request
> and offers s1 but not s0 for a another request occurring at the same time. This
> may be a totally obvious and acceptable restriction to you. I don't know OSGI
> well enough to tell in advance.
> Alternatively, you could implement your own Marker implementation and your own
> marker factory, allowing you to check if a marker is a "bundle marker" or a
> "service marker" or some other type. You could iterate only though bundle
> markers or only through service markers. As long as the markers you pass to
> logback implement the org.slf4j.Marker interface, logback does not care.
thanks - it helps to make it more clear
I want to have this functionality of Bundle- and ServiceMarkers, because
the OSGI LogServices
always have a bundleContext and ServiceReference(s) contained in the
If I catch these log entries and route them to LOGBack I dont want to
Also if I'm doing my own logs from my bundles I also want to log the
bundle name and
names of referenced services
now I have some ideas how to solve it best
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Logback-user