• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Help needed on File logging

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have tried to write a common logging class that writes to a file.



I call the static methods of this class to get logger objects and whenever I need to write to a file. Currently, when I execute this, several log files get generated as well as '.lck' files in the current working dir. I am not sure why I am getting this behaviour (more than one log file and .lck file).

Any help is appreciated.

thanks

Stan
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think there are a couple of problems here. Each time you call your static methods that in turn creates a brand new instance of FileHandler class.

Instead you should create only one instance of the FileHandler class for each log file and work with that.

As a side note, both of you static methods (getClientLogger and getServerLogger) are nearly identical. Sun may take points off for that since this is generally a bad programming practice.

Instead try creating only one method (getLogger) and make it take some kind of parameter that will differentiate between the different logging modes (client & server). Doing so will half the size of you FileLogger class.
 
Stan Griffith
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Yevgeniy. It worked for me. Sorry for the delaye in responding.

Stan
 
Bras cause cancer. And tiny ads:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic