By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,215 Members | 1,936 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,215 IT Pros & Developers. It's quick & easy.

Problem with JDK1.4 logging framework

P: 3
Hi,
I am using JDK1.4 logging framework and below are the properties that I have in my logging.properties file to configure logging..

handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
.level= INFO
java.util.logging.ConsoleHandler.level=SEVERE
java.util.logging.ConsoleHandler.formatter=java.ut il.logging.SimpleFormatter
java.util.logging.FileHandler.level=INFO
java.util.logging.FileHandler.pattern=%h/java%u.log
java.util.logging.FileHandler.append=true
java.util.logging.FileHandler.limit= 50000
java.util.logging.FileHandler.count= 1
java.util.logging.FileHandler.formatter=java.util. logging.SimpleFormatter

Using this every time I run my application the desired log file is getting genrated and apart from that additional files are being created like:

if my log file name is logger.log

logger.log.1
logger.log.2
logger.log.3
logger.log.4
logger.log.5
logger.log.6
logger.log.7
logger.log.1.lck
logger.log.2.lck
logger.log.3.lck
logger.log.4.lck
logger.log.5.lck
logger.log.6.lck
logger.log.7 .lck

Can anybody suggest how to avoid these files?
Aug 18 '07 #1
Share this Question
Share on Google+
3 Replies


Expert 10K+
P: 11,448
Can anybody suggest how to avoid these files?
These lock files (.lck) indicate that you haven't closed your Handlers when your
program terminates. The next time logging starts, it finds these lock files and
creates a new log file.

Try:

Expand|Select|Wrap|Line Numbers
  1. LogManager.getLogManager().reset();
  2.  
... or close all Handlers explitly.

kind regards,

Jos
Aug 18 '07 #2

P: 3
These lock files (.lck) indicate that you haven't closed your Handlers when your
program terminates. The next time logging starts, it finds these lock files and
creates a new log file.

Try:

Expand|Select|Wrap|Line Numbers
  1. LogManager.getLogManager().reset();
  2.  
... or close all Handlers explitly.

kind regards,

Jos
Hi,
I tried closing my logger handlers with the following method:
public void closeLogger(){
Handler[] handlers = logger.getHandlers();
for(int i=0; i<handlers.length; i++){
handlers[i].close();
}
}

But still the problem persists.
I tried LogManager.getLogManager().reset(); as well and it only reduces the number of .lck files that are getting generated.
Any suggestions?

Regards,
Pundarikakshaiah
Aug 20 '07 #3

P: 3
Hi,
One way I could resolve this issue is by making my logger class as singleton and all the other classes in my application use this single instance to log the information. I have noticed that each time I invoke the Logger.getLogger() method to get a logger for a class, a corresponding numbered log and .lck file is getting generated.

But still when we make it a singleton class it generates one .lck file for my log file. For ex: if my log file name is a.log, it generates a.log.lck as well.

While dicussing with one of my friend I came to know that this issue has been resolved in JDK1.5 Loging framework.

Regards,
Pundarikakshaiah
Aug 21 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.