• 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

Logfile from different classes

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do i create a logfile that can be accessed from different classes. I only want to use one logfile which will be open while the application i make is running. It will only close when i close my application. I have many classes in different files. What can i do to make the Log class a public accessible class to all the others.
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could apply the Singleton pattern for the Logger class (all code would use Logger.getInstance(), and get a reference to the same Logger instance).
This Logger class should be able to handle input from different threads at once, to avoid intermixed output in the file.
Hope this helps.
Regards,
G�nther.
http://www.javacoding.net
 
reply
    Bookmark Topic Watch Topic
  • New Topic