It's not a secret anymore!*
The moose likes Beginning Java and the fly likes Logging problem .Too many .lck files created. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

Logging problem .Too many .lck files created.

madhup narain
Ranch Hand

Joined: Dec 14, 2004
Posts: 148
Hi,

I have been trying my hand with the logging API of java and want to implement it.Have had some success with it.

I have noticed while using Files for logging .lck files (which are LOCK files ) are created and the .lck files may become too large. What i dont understand is why are many .lck files created and why dosent the system remove them once the process is through with writing.

My second problem is that every time an information is entered in the Log file there is a 'Particular' data time format that is appended with the information. I would not tike the data-time combination being printed every time as it makes information quite hard to decipher.

Below is the code i used..
.
.
.
Logger oLogger = Logger.getLogger("LOGGER");
FileHandler oFileHandler = new FileHandler("my.txt", true);
oFileHandler .setFormatter(new SimpleFormatter());
oLogger.addHandler(oFileHandler);
.
.
.
oLogger.logp(Level.WARNING,"Array","main","This is a warning");
oLogger.logp(Level.WARNING,"Array","main","This is a warning");
oLogger.logp(Level.WARNING,"Array","main","This is a warning");
.
.

The output i get is..
9/05/2005 10:44:40 Array main
WARNING: This is a warning
9/05/2005 10:44:40 Array main
WARNING: This is a warning
9/05/2005 10:44:40 Array main
WARNING: This is a warning

what i would like...is date and Time to be formatted..Perhaps not be there
and how do i get rid of .lck files.

in my case .lck files ranged from
my.txt.1
my.txt.1.lck

to
my.txt.15
my.txt.1.lck

those are 30 files and i am wasting space....as well as complicating things

Regards
Madhup


Money for nothing and Java for Free
SCJP, SCWCD
madhup narain
Ranch Hand

Joined: Dec 14, 2004
Posts: 148
Ok guys,

was able to figure out why so many lock files were created, but i need a way to format the data and the time thats being appended to the LOG messages.

regards
sweety kamal
Greenhorn

Joined: Feb 04, 2011
Posts: 4
please post the solution I am stuck with .lck
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11161
    
  16

sweety kamal wrote:please post the solution I am stuck with .lck

you realize this thread is over six years old?

If you have a problem, i would suggest you create your own thread, post all the relevant information, and go from there.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Logging problem .Too many .lck files created.
 
Similar Threads
logging solution
Help needed on File logging
Logging level question
re: Java Logger Class
re: help appreciated