Win a copy of Machine Learning with R: Expert techniques for predictive modeling this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Log4J and Threading

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
Good point.
 
Getting married means "We're in love, so let's tell the police!" - and invite this tiny ad to the wedding:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!