You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by David Bosschaert <da...@gmail.com> on 2012/03/02 10:52:50 UTC
JNDI log messages
Another email about logging ...
During the integration of the Aries JNDI component in our project we
hit an issue with the log messages emitted from
https://svn.apache.org/repos/asf/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java
Specifically the following block (there is a second block just like
this one too):
try {
OSGiInitialContextFactoryBuilder builder = new
OSGiInitialContextFactoryBuilder();
NamingManager.setInitialContextFactoryBuilder(builder);
icfBuilder = builder;
} catch (NamingException e) {
LOGGER.info(Utils.MESSAGES.getMessage("unable.to.set.static.ICFB"), e);
} catch (IllegalStateException e) {
LOGGER.info(Utils.MESSAGES.getMessage("unable.to.set.static.ICFB.already.exists",
getClassName(InitialContextFactoryBuilder.class)), e);
}
In our case the InitialContextFactoryBuilder is already set, so there
will be an IllegalStateException, but this is totally harmless in our
case. It's fine to log an INFO message, but we don't want the
exception to appear at this level, as that gets people worried,
therefore, would it be acceptable to change the log message to
something like this?
LOGGER.info(Utils.MESSAGES.getMessage("unable.to.set.static.ICFB.already.exists",
getClassName(InitialContextFactoryBuilder.class)));
LOGGER.debug(Utils.MESSAGES.getMessage("unable.to.set.static.ICFB.already.exists",
getClassName(InitialContextFactoryBuilder.class)), e);
So that the message is still logged at debug level but the exception
only appear at Debug level?
Thanks,
David
Re: JNDI log messages
Posted by David Bosschaert <da...@gmail.com>.
On 2 March 2012 09:52, David Bosschaert <da...@gmail.com> wrote:
> Another email about logging ...
>
> During the integration of the Aries JNDI component in our project we
> hit an issue with the log messages emitted from
> https://svn.apache.org/repos/asf/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java
>
> Specifically the following block (there is a second block just like
> this one too):
>
> try {
> OSGiInitialContextFactoryBuilder builder = new
> OSGiInitialContextFactoryBuilder();
> NamingManager.setInitialContextFactoryBuilder(builder);
> icfBuilder = builder;
> } catch (NamingException e) {
> LOGGER.info(Utils.MESSAGES.getMessage("unable.to.set.static.ICFB"), e);
> } catch (IllegalStateException e) {
> LOGGER.info(Utils.MESSAGES.getMessage("unable.to.set.static.ICFB.already.exists",
> getClassName(InitialContextFactoryBuilder.class)), e);
> }
>
> In our case the InitialContextFactoryBuilder is already set, so there
> will be an IllegalStateException, but this is totally harmless in our
> case. It's fine to log an INFO message, but we don't want the
> exception to appear at this level, as that gets people worried,
> therefore, would it be acceptable to change the log message to
> something like this?
>
> LOGGER.info(Utils.MESSAGES.getMessage("unable.to.set.static.ICFB.already.exists",
> getClassName(InitialContextFactoryBuilder.class)));
> LOGGER.debug(Utils.MESSAGES.getMessage("unable.to.set.static.ICFB.already.exists",
> getClassName(InitialContextFactoryBuilder.class)), e);
>
> So that the message is still logged at debug level but the exception
> only appear at Debug level?
That should have said:
So that the message is still logged at Info level but the exception
only appears at Debug level?
David
Re: JNDI log messages
Posted by Guillaume Nodet <gn...@gmail.com>.
Isn't that a real problem if the factory is already set ? Or is that a
valid use case ?
On Fri, Mar 2, 2012 at 10:52, David Bosschaert
<da...@gmail.com>wrote:
> Another email about logging ...
>
> During the integration of the Aries JNDI component in our project we
> hit an issue with the log messages emitted from
>
> https://svn.apache.org/repos/asf/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java
>
> Specifically the following block (there is a second block just like
> this one too):
>
> try {
> OSGiInitialContextFactoryBuilder builder = new
> OSGiInitialContextFactoryBuilder();
> NamingManager.setInitialContextFactoryBuilder(builder);
> icfBuilder = builder;
> } catch (NamingException e) {
> LOGGER.info(Utils.MESSAGES.getMessage("unable.to.set.static.ICFB"), e);
> } catch (IllegalStateException e) {
>
> LOGGER.info(Utils.MESSAGES.getMessage("unable.to.set.static.ICFB.already.exists",
> getClassName(InitialContextFactoryBuilder.class)), e);
> }
>
> In our case the InitialContextFactoryBuilder is already set, so there
> will be an IllegalStateException, but this is totally harmless in our
> case. It's fine to log an INFO message, but we don't want the
> exception to appear at this level, as that gets people worried,
> therefore, would it be acceptable to change the log message to
> something like this?
>
>
> LOGGER.info(Utils.MESSAGES.getMessage("unable.to.set.static.ICFB.already.exists",
> getClassName(InitialContextFactoryBuilder.class)));
>
> LOGGER.debug(Utils.MESSAGES.getMessage("unable.to.set.static.ICFB.already.exists",
> getClassName(InitialContextFactoryBuilder.class)), e);
>
> So that the message is still logged at debug level but the exception
> only appear at Debug level?
>
> Thanks,
>
> David
>
--
------------------------
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
FuseSource, Integration everywhere
http://fusesource.com