• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Log4j "extremely slow" options

Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am optimizing an application that uses Java 1.3 and log4j. Our config file says:

The %C displays the name of the caller class, and the %L displays the line number. I noticed that http://logging.apache.org/log4j/docs/api/org/apache/log4j/PatternLayout.html says that these options are "extremely slow". But I hesitate to remove them, because they do provide good information.

I wonder how other people have handled this. Is there some faster alternative to %C and %L that would provide similar information?
Posts: 26767
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you do some profiling that showed those calls were a target for optimization? If not, then I would suggest running tests with and without those options. You might find they aren't a problem. On the other hand if you find that line number is useful information, that suggests you are doing a large amount of logging.

If they are a problem, though, my guess would be that they are the best possible way of producing that information. The supporting documentation for log4j does discuss the possible performance impacts of logging, so it seems unlikely to me that the people who wrote it deliberately implemented those features in a suboptimal way.
    Bookmark Topic Watch Topic
  • New Topic