Why is my program creating empty .lck files?

Roman picture Roman · Apr 27, 2010 · Viewed 34.9k times · Source

I am trying to use Java Logger. I get my logger file (name.log) with the content, it works and I also get an empty name.log.lck file.

Why does this file appear, what program is creating them and how I can remove this behavior?

Answer

Rana picture Rana · Oct 1, 2010

.lck is used by the handler(file handler) to lock the file in order to delete this file. You need to close the Handler that is associated with that logger object before you close your program.

Here is sample lines how you can close associated handler:

for(Handler h:log.getHandlers())
{
    h.close();   //must call h.close or a .LCK file will remain.
}