• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Log4J and Threading

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a multi-threaded application logging via Log4j. Does anyone know what the relationship is between instances of Loggers and instances of Appenders?
regards
Paul.
 
Paul Rhoades
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've done a quick test and it appears that multiple instances of logger from separate threads direct output to a single instance of an appender. Looking at the (log4j) call stack a synchronisation on the current logger instance is performed but this won't prevent other loggers / threads from calling the same appender, and therefore Appenders must be written to be thread safe.
My only issue with this is that it introduces a choke point and therefore hinders performance.
Anyone disagree?
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Rhoades:
My only issue with this is that it introduces a choke point and therefore hinders performance.


Well, somehow the output *has* to be synchronized, if you don't want it to be badly intermingled. So the only question is where to put the "choke point". Appender sounds reasonable to me.
 
Paul Rhoades
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good point.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic