Logger performance

Discussion in 'Java' started by Kenneth P. Turvey, Sep 18, 2005.

  1. -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    I was looking at the Logger classes the other day and I read some claims
    about the performance of the Logger that I found a bit hard to believe.

    Ideally what one would like is a system like the assertion system where
    logging code is only executed when it is above the level being filtered
    by the logging system so code like this:

    thisLogger.finest("My info: " + SomeObject.performComplexCalculation());

    would not execute except when the user was requesting logging at the
    finest level.

    I don't believe the Logger is handled this way. It would require
    compiler support that I don't believe exists, wouldn't it?

    Am I correct in understanding that logging should not be used in inner
    loops, even for debugging (if it will be in the code in production)?

    Thanks.

    - --
    Kenneth P. Turvey <>
    http://kt.squeakydolphin.com (not much there yet)
    Jabber IM:
    Phone: (314) 255-2199

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.1 (GNU/Linux)

    iD8DBQFDLeDq3naBnF2rJNURAtyZAKDFGo4CopQkwj3l+UWjXSAd/9e4tACfWX6J
    5MomPDKF+vrHRTPQku8Lpuo=
    =SMUy
    -----END PGP SIGNATURE-----
     
    Kenneth P. Turvey, Sep 18, 2005
    #1
    1. Advertising

  2. Kenneth P. Turvey

    Guest

    Kenneth P. Turvey skrev:

    > -----BEGIN PGP SIGNED MESSAGE-----
    > Hash: SHA1
    >
    > I was looking at the Logger classes the other day and I read some claims
    > about the performance of the Logger that I found a bit hard to believe.
    >


    > -----END PGP SIGNATURE-----



    To add to the excellent answer already received, see:
    http://www.javaalmanac.com/egs/java.util.logging/Minimize.html?l=rel

    I fear your fears are justified.

    ..ed

    --
    www.EdmundKirwan.com - Home of The Fractal Class Composition.
     
    , Sep 19, 2005
    #2
    1. Advertising

  3. Kenneth P. Turvey, Sep 19, 2005
    #3
  4. Kenneth P. Turvey

    Chris Uppal Guest

    Kenneth P. Turvey wrote:

    > That's too bad. Having all this code for logging really clutters the
    > code. There must be a better way.


    AspectJ ?

    -- chris
     
    Chris Uppal, Sep 19, 2005
    #4
  5. In article <>,
    "Kenneth P. Turvey" <> wrote:

    > On Mon, 19 Sep 2005 07:02:24 -0700, iamfractal wrote:
    >
    > > To add to the excellent answer already received, see:
    > > http://www.javaalmanac.com/egs/java.util.logging/Minimize.html?l=rel
    > >
    > > I fear your fears are justified.

    >
    > That's too bad. Having all this code for logging really clutters the
    > code. There must be a better way.


    I have never found

    if (logger.isLoggable(Level.FINEST)) {
    logger.finest("count: "+count);
    }

    to be all that bad, but then I tend to have some very distinct patterns
    in my logging code. For example, I log entry and exit at the top and
    bottoms of methods, so I tend not to see those lines.

    I suspect aspects are really the only way to get this to be clean, or
    log/nolog versions of the code generated from some template or Aspect
    system.

    Scott

    --
    Scott Ellsworth

    Java and database consulting for the life sciences
     
    Scott Ellsworth, Sep 19, 2005
    #5
  6. Kenneth P. Turvey

    Guest

    Try SuperLogging from http://www.acelet.com/super/SuperLogging
    You can dynamicall filter our unwanted messages: set log level,
    register class... It is free.

    Make your code simple. Any bug in log area is very difficult to debug:
    you do not have all the condition to test it.


    Kenneth P. Turvey wrote:
    > -----BEGIN PGP SIGNED MESSAGE-----
    > Hash: SHA1
    >
    > I was looking at the Logger classes the other day and I read some claims
    > about the performance of the Logger that I found a bit hard to believe.
    >
    > Ideally what one would like is a system like the assertion system where
    > logging code is only executed when it is above the level being filtered
    > by the logging system so code like this:
    >
    > thisLogger.finest("My info: " + SomeObject.performComplexCalculation());
    >
    > would not execute except when the user was requesting logging at the
    > finest level.
    >
    > I don't believe the Logger is handled this way. It would require
    > compiler support that I don't believe exists, wouldn't it?
    >
    > Am I correct in understanding that logging should not be used in inner
    > loops, even for debugging (if it will be in the code in production)?
    >
    > Thanks.
    >
    > - --
    > Kenneth P. Turvey <>
    > http://kt.squeakydolphin.com (not much there yet)
    > Jabber IM:
    > Phone: (314) 255-2199
    >
    > -----BEGIN PGP SIGNATURE-----
    > Version: GnuPG v1.4.1 (GNU/Linux)
    >
    > iD8DBQFDLeDq3naBnF2rJNURAtyZAKDFGo4CopQkwj3l+UWjXSAd/9e4tACfWX6J
    > 5MomPDKF+vrHRTPQku8Lpuo=
    > =SMUy
    > -----END PGP SIGNATURE-----
     
    , Sep 20, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kenneth P. Turvey

    Logger performance

    Kenneth P. Turvey, Sep 19, 2005, in forum: Java
    Replies:
    3
    Views:
    435
    Roedy Green
    Sep 20, 2005
  2. Kenneth P. Turvey

    Logger Performance

    Kenneth P. Turvey, Sep 19, 2005, in forum: Java
    Replies:
    1
    Views:
    338
    EricF
    Sep 19, 2005
  3. sachin
    Replies:
    1
    Views:
    991
    Soren Kuula
    Feb 3, 2006
  4. cap
    Replies:
    3
    Views:
    312
    James Edward Gray II
    Dec 11, 2005
  5. Georges Ko
    Replies:
    4
    Views:
    291
    Georges Ko
    Jul 26, 2006
Loading...

Share This Page