This project was handed over to me, so I know little about it. There is a method that uses log (java.util.logging.Logger) and it creates two log files:
First file: fileName.log
Second file: fileName.log.lck
On Linux, when I do lsof , I see these two files as open. How to close these two files?
The reason I want to close these files is because this method runs several times a day, and after a couple of weeks the number of open files reaches the limit (about 1000), and at this point our system stops working. When we restart our process (the "Job Controller" that does the logging), the number of open log files goes to 0 and runs again.
This is what was done for logging.
private static Logger log = Logger.getLogger(MyClass.class.getPackage().getName()); try{ log.logp(Level.SEVERE, "com.MyClass", "run", "It failed"); }
This is what I tried to do to close the files in the finally block, but it did not work
finally{ Handler[] handler = log.getHandlers(); for(Handler h: handler){ h.close(); } }
Susie source share