Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my program creating empty .lck files?

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?

like image 896
Roman Avatar asked Apr 27 '10 17:04

Roman


People also ask

Why is a .LCK file created?

An LCK file is an access control file used to "lock" a database or other file from being opened or changed by more than one user at a time. It prevents users from accidentally overwriting changes and possible data corruption.

What is .LCK file in VMware?

Lock files are created when a virtual machine is powered on. Their purpose is to prevent multiple VMware processes from accessing the same virtual machine at the same time. The existence of a lock file indicates to VMware that the associated virtual machine is powered on.


1 Answers

.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.
}
like image 109
Rana Avatar answered Sep 18 '22 12:09

Rana