Problem with JDK1.4 logging framework

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pundarikakshaiah
    New Member
    • Aug 2007
    • 3

    Problem with JDK1.4 logging framework

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

    handlers= java.util.loggi ng.FileHandler, java.util.loggi ng.ConsoleHandl er
    .level= INFO
    java.util.loggi ng.ConsoleHandl er.level=SEVERE
    java.util.loggi ng.ConsoleHandl er.formatter=ja va.util.logging .SimpleFormatte r
    java.util.loggi ng.FileHandler. level=INFO
    java.util.loggi ng.FileHandler. pattern=%h/java%u.log
    java.util.loggi ng.FileHandler. append=true
    java.util.loggi ng.FileHandler. limit= 50000
    java.util.loggi ng.FileHandler. count= 1
    java.util.loggi ng.FileHandler. formatter=java. util.logging.Si mpleFormatter

    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.lc k
    logger.log.2.lc k
    logger.log.3.lc k
    logger.log.4.lc k
    logger.log.5.lc k
    logger.log.6.lc k
    logger.log.7 .lck

    Can anybody suggest how to avoid these files?
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by pundarikakshaia h
    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:

    [code=java]
    LogManager.getL ogManager().res et();
    [/code]

    ... or close all Handlers explitly.

    kind regards,

    Jos

    Comment

    • pundarikakshaiah
      New Member
      • Aug 2007
      • 3

      #3
      Originally posted by JosAH
      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:

      [code=java]
      LogManager.getL ogManager().res et();
      [/code]

      ... 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.getHandl ers();
      for(int i=0; i<handlers.leng th; i++){
      handlers[i].close();
      }
      }

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

      Regards,
      Pundarikakshaia h

      Comment

      • pundarikakshaiah
        New Member
        • Aug 2007
        • 3

        #4
        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.getLogge r() 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,
        Pundarikakshaia h

        Comment

        Working...