dev@glassfish.java.net

Re: Logger info

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Tue, 16 Sep 2008 17:06:14 -0700

Jerome,

We are passing in a class, not a class loader to LogDomains.getLogger() :).

thanks,
-marina

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
>