• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

log4j question

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Is it possible to unlock log file before program ends?

My GUI application logs messages in files which names contain current date (e.g. log-2006-10-03-15-49-52.log).
I want to delete old logs whithout closing application, but it cannot be done because file is locked.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I want to delete old logs



What appender are you using? Is it RollingFileAppender or something similar? If yes then log4j has already taken care of calling close() on the appender when the file is being rolled. So you should be able to delete the *old* file which is no longer being used.

However if you are having your own logic of rolling over the files, then you will have to take care of closing the old file while doing a roll over
 
Lukas Stephienn
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I solve it.

After job's done, I simply remove appenders. And before job starts i just add them. Very simple.

Thanks for help anyway.
 
reply
    Bookmark Topic Watch Topic
  • New Topic