You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Shawn Jiang <ge...@gmail.com> on 2011/05/18 14:50:29 UTC

Questions on logger in openejb source code.

Hi Devs,

Actually,  I have two questions on openejb logger.

1,   What's the benefit to use a customized logger factory with assigned
category ?

2,  What's the reason to use   "org.apache.openejb.util.resources"  instead
of the owner class name  as the loggers' basename in most of classes ?


An example of #2 above could be found in MdbInstanceFactory:

org.apache.openejb.core.mdb.MdbInstanceFactory.logger =
Logger.getInstance(LogCategory.OPENEJB,
"org.apache.openejb.util.resources");


-- 
Shawn

Re: Questions on logger in openejb source code.

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi Shawn,

David will have a better answer but i think it is to have more linear and
standardized logs @ boot and run time.

- Romain

2011/5/18 Shawn Jiang <ge...@gmail.com>

> Hi Devs,
>
> Actually,  I have two questions on openejb logger.
>
> 1,   What's the benefit to use a customized logger factory with assigned
> category ?
>
> 2,  What's the reason to use   "org.apache.openejb.util.resources"  instead
> of the owner class name  as the loggers' basename in most of classes ?
>
>
> An example of #2 above could be found in MdbInstanceFactory:
>
> org.apache.openejb.core.mdb.MdbInstanceFactory.logger =
> Logger.getInstance(LogCategory.OPENEJB,
> "org.apache.openejb.util.resources");
>
>
> --
> Shawn
>

Re: Questions on logger in openejb source code.

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi,

slf4j support internationalisation: http://www.slf4j.org/localization.html

i'm agree with Shawn and David, IMHO INFO (and >) messages should be logged
with the category and under the INFO level (DEBUG, ...) it should be with
the class name because it is developers oriented. So maybe a wrapping is
still needed:

// in pseudo - code
public class Logger {
    public Logger(Class<?> clazz, LoggerCategory cat) { ...}
    public void info() { LoggerFactory.getLogger(cat).info(); }
    public void debug() { LoggerFactory.getLogger(clazz).debug(); }
...
}

I prefer to keep slf4j as interface (it can be used with a lot of
implementations :)) because java.util.logging can be a bit limited in some
cases (not for testing of course but for production) for example.

- Romain

2011/5/19 Shawn Jiang <ge...@gmail.com>

> On Thu, May 19, 2011 at 12:46 PM, David Blevins <david.blevins@gmail.com
> >wrote:
>
> > The Logger class is maybe 10 years old.  There maybe better ways to do
> > stuff now, but here's what it does...
> >
> > On May 18, 2011, at 5:50 AM, Shawn Jiang wrote:
> >
> > > 1,   What's the benefit to use a customized logger factory with
> assigned
> > > category ?
> >
> > The i18n support is behind the logger API.  Might be a more modern way to
> > do that these days.
> >
> > The categories are nice instead of packages as we occasionally move code
> > around between classes or packages and the configured log output remains
> > stable.  Most the categories are used by several parts of the code which
> is
> > nice as it keeps things simple from a configuration perspective.
> >
> > Basically, most administrators don't care about the structure of our code
> > and don't want to be bothered when it changes.
> >
>
> One of important functions of log is for developer/L3 to locate where does
> the error happen.   I used to use the class name in the log entry  and "ctl
> +T" in eclipse to locate the class.  But with the default category logging
> way,  I have to use the logging message string as key word to search in
> full
> text  to locate where does the log message come from.
>
> Maybe it's easy to turn on class/method displaying with log4j.properties in
> openejb.    But I don't know how to do this for openejb in geronimo.
>
>
> >
> > > 2,  What's the reason to use   "org.apache.openejb.util.resources"
> >  instead
> > > of the owner class name  as the loggers' basename in most of classes ?
> >
> > That one is legacy.  We should split up all those messages into the
> related
> > parts of code.
> >
>
> From my understanding,  we should change these
> "org.apache.openejb.util.resources"  to the class name as a first step to
> improve them.
>
>
> >
> > As long as we're on the subject we should take another shot at switching
> > our default over to java.util.logging.  If we can get the same output
> format
> > from java.util.logging and lose a log4j dependency, that could be nice.
> >
> >
> > -David
> >
> >
>
>
> --
> Shawn
>

Re: Questions on logger in openejb source code.

Posted by Shawn Jiang <ge...@gmail.com>.
On Thu, May 19, 2011 at 12:46 PM, David Blevins <da...@gmail.com>wrote:

> The Logger class is maybe 10 years old.  There maybe better ways to do
> stuff now, but here's what it does...
>
> On May 18, 2011, at 5:50 AM, Shawn Jiang wrote:
>
> > 1,   What's the benefit to use a customized logger factory with assigned
> > category ?
>
> The i18n support is behind the logger API.  Might be a more modern way to
> do that these days.
>
> The categories are nice instead of packages as we occasionally move code
> around between classes or packages and the configured log output remains
> stable.  Most the categories are used by several parts of the code which is
> nice as it keeps things simple from a configuration perspective.
>
> Basically, most administrators don't care about the structure of our code
> and don't want to be bothered when it changes.
>

One of important functions of log is for developer/L3 to locate where does
the error happen.   I used to use the class name in the log entry  and "ctl
+T" in eclipse to locate the class.  But with the default category logging
way,  I have to use the logging message string as key word to search in full
text  to locate where does the log message come from.

Maybe it's easy to turn on class/method displaying with log4j.properties in
openejb.    But I don't know how to do this for openejb in geronimo.


>
> > 2,  What's the reason to use   "org.apache.openejb.util.resources"
>  instead
> > of the owner class name  as the loggers' basename in most of classes ?
>
> That one is legacy.  We should split up all those messages into the related
> parts of code.
>

>From my understanding,  we should change these
"org.apache.openejb.util.resources"  to the class name as a first step to
improve them.


>
> As long as we're on the subject we should take another shot at switching
> our default over to java.util.logging.  If we can get the same output format
> from java.util.logging and lose a log4j dependency, that could be nice.
>
>
> -David
>
>


-- 
Shawn

Re: Questions on logger in openejb source code.

Posted by David Blevins <da...@gmail.com>.
The Logger class is maybe 10 years old.  There maybe better ways to do stuff now, but here's what it does...

On May 18, 2011, at 5:50 AM, Shawn Jiang wrote:

> 1,   What's the benefit to use a customized logger factory with assigned
> category ?

The i18n support is behind the logger API.  Might be a more modern way to do that these days.

The categories are nice instead of packages as we occasionally move code around between classes or packages and the configured log output remains stable.  Most the categories are used by several parts of the code which is nice as it keeps things simple from a configuration perspective.

Basically, most administrators don't care about the structure of our code and don't want to be bothered when it changes.

> 2,  What's the reason to use   "org.apache.openejb.util.resources"  instead
> of the owner class name  as the loggers' basename in most of classes ?

That one is legacy.  We should split up all those messages into the related parts of code.

As long as we're on the subject we should take another shot at switching our default over to java.util.logging.  If we can get the same output format from java.util.logging and lose a log4j dependency, that could be nice.


-David


Re: Questions on logger in openejb source code.

Posted by Karan Malhi <ka...@gmail.com>.
Hi Shawn,,

Please have a look at this http://openejb.apache.org/logging.html

On Wed, May 18, 2011 at 8:50 AM, Shawn Jiang <ge...@gmail.com> wrote:

> Hi Devs,
>
> Actually,  I have two questions on openejb logger.
>
> 1,   What's the benefit to use a customized logger factory with assigned
> category ?
>
> 2,  What's the reason to use   "org.apache.openejb.util.resources"  instead
> of the owner class name  as the loggers' basename in most of classes ?
>
>
> An example of #2 above could be found in MdbInstanceFactory:
>
> org.apache.openejb.core.mdb.MdbInstanceFactory.logger =
> Logger.getInstance(LogCategory.OPENEJB,
> "org.apache.openejb.util.resources");
>
>
> --
> Shawn
>



-- 
Karan Singh Malhi