• 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

Best Way to Use LOG4J

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
From Architecture point of view what could be the best practices to use Log4J. What are diffrent norms we should follow to acheive architectural goal (Performance /scaling, etc), when using Log4J.

How Log4j (Appender)writes event messages to a log file ? It collects certain meessage in buffer and then write in one I/O ?? or For every even log it make one I/O ??

How we can minimise the I/O calls, during Logging??

Regards,
SS
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
If you are worried about performance you can use the org.apache.log4j.AsyncAppender.
This will writes to the log file asynchronous. You can define your buffer size in log4j.xml. You must define the AsyncAppender in xml format this cannot be done in the .properties format. Also if you use this one make sure you call LogManager.shutdown() at application shutdown so the last lines are flushed to the log file.

Lars
 
Siyaram Singh
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lars,
Thanks a lot !
1. If AsyncAppender is not used, then how log4J writes log event to the file ? It uses any default buffer or It writes one by one event message in log file, I mean one even message = one I/O ???

2 If we use AsyncAppender and setBufferSize(int size).
And Configure Buffer size in log4j.xml.
If set value in setBufferSize(int size) is less than Buffer size in log4j.xml ???
How both are related and what would be the optimum guidlines ???
(default buffer size is set to 128 events)

3. Also I would like to know the actual / practical way to diffrentiate the FATAL, ERROR,INFO.
Is realy FATAL should be used for Business related error ??

Regards,
Siyaram
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic