dev@glassfish.java.net

Re: Logger info

From: Tim Quinn <Timothy.Quinn_at_Sun.COM>
Date: Thu, 18 Sep 2008 09:30:38 -0500

OK, I am being a good citizen and going through the deployment uses of
LogDomains.getLogger and changing them all to follow Jerome's technique
#2.2.

Two questions now:

1. (which I posed last night) Do we need to add the path where the
LogStrings.properties resides to the osgi.bundle file for the common module?

2. Where is the root logger and what class should I pass in searching
for it? There is some code in deployment which tries to find the
deployment logger and, if that fails, tries to find the root logger
instead.

Thanks.

- Tim

Jerome Dochez wrote:
> Hi All
>
> Following the conversation we had during the dev meeting today. The
> easiest way to ensure proper loading of your logStrings.properties
> file depends on the following conditions :
>
> First remember that loggers in GlassFish are organized per functional
> area so you have a unique Web, and EJB, an admin logger instance.
>
> 1. only one bundle uses the logger instance :
> 1.1 place the resource inside that bundle, at the top of your
> hierarchy or work with Carla on the full path you should use for your
> file.
> 1.2 use LogDomains.getLogger(this.getClass().getClassLoader(),
> LogDomains.Web) to access your instance.
>
> 2. mulitple bundles use the same logger instance :
> - place the resource in the common bundle (the one imported by all
> the others, you usually have that, worse case, put it in common-util,
> it's imported by everyone.
> - do either one of the 2 actions :
> 2.1 Rely on OSGi import/export
> For example, you want to share a
> com.sun.logging.enterprise.system.container.web.LogStrings.properties, do
> 2.1.1. export the package from the bundle containing the
> resource
>
> -exportcontents: \
> com.sun.enterprise.glassfish.web, \
> +
> com.sun.logging.enterprise.system.container.web, \
>
> 2.1.2 import that package in all bundles sharing the logger
>
> Import-Package: \
> +
> com.sun.logging.enterprise.system.container.web, \
> 2.1.3 use
> LogDomains.getLogger(this.getClass().getClassLoader(), LogDomains.WEB);
>
>
> 2.2 Rely on BND to do the package import/export by using a class
> dependency
>
> 2.2.1 Say that your common bundle that has the resource also has a
> class called org.glassfish.util.Random, you can just do
> Logger logger =
> LogDomains.getLogger(org.glassfish.util.Random.class, LogDomains.WEB);
>
> as you can see 2.2 is the easiest when dealing with multiple bundles
> sharing a Logger and therefore a resource bundle. The key is to give
> to the LogDomains.getLogger API a instance of type Class which
> classloader's can be used to load the associated resource bundle.
>
> Jerome
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>