I have a little routine that schedules a timer like that:
timer.schedule(new myRoutine(), 1000, 60000);
In the run()
method of myRoutine
a logger
is opened and a FileHandler
is attached to it:
FileHandler fh = new FileHandler("app.log"),true);
logger.addHandler(fh);
Since there is no real exit point to the application (as it runs as a service), i have no chance to close and remove the logger
´s FileHandler
, hence the file lock (app.log.lck
) remains, resulting in a new logfile (app.log.1
) on next start of the service.
Is there a way to ensure the FileHandler
is closed and removed?