List Info

Thread: logger settings




logger settings
user name
2007-07-29 04:27:16
Hi All,
 
After spending 5 hours (!) figuring out why my debug messages are not shown, and why log file is not created, I learned that this is an initialization "property file" ;issue.
 
To cope with this implicitly, I have created a method that check to see if log file is registered and if not, make the registering.
 
You might want to add it to the logger.java code:
 
   
  /**
   ;  *  SETUP the logger propery values so log file will produce and FINE messgaes gets recorded
    ; *
     *  Check that some logger initializeation paramteres exists. If not do make some defualt initialization.
 ;    *  It was developed because the ConsoleLogger did not output debug ('fine") information.
     * Author Michael Kraizleman at 29 July 2007
 ;    */
    private  static void checkInitializationParameters() {
       ; LogManager logManager = LogManager.getLogManager();
        String value = logManager.getProperty("java.util.logging.FileHandler");
       ; if (value != null && value.length() > 0) return;
      
        String params =
"# "handlers" specifies a comma separated list of log Handler n" +
"# classes.  These handlers will be installed during VM startup. n" +
"# Note that these classes must be on the system classpath. n" +
"# By default we only configure a ConsoleHandler, which will only n" +
"# show messages at the INFO and above levels. n" +
"handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler n" +
"n" +
"# Default global logging level. n" +
"# This specifies which kinds of events are logged across n" +
"# all loggers.  For any given facility this global level n" +
"# can be overriden by a facility specific level n" +
"# Note that the ConsoleHandler also has a separate level n" +
"# setting to limit messages printed to the console.  n" +
".level= FINE n" +
"n" +
"############################################################n" +
"# Handler specific properties.n" +
"# Describes specific configuration info for Handlers.n" +
"############################################################" +
"# default file output is in user's home directory.n" +
"java.util.logging.FileHandler.pattern = %h/.sip-communicator/log/sip-communicator%u.logn" +
"java.util.logging.FileHandler.limit = 5000000n" +
"java.util.logging.FileHandler.count = 1n" +
"java.util.logging.FileHandler.formatter = net.java.sip.communicator.util.ScLogFormattern" +
"java.util.logging.FileHandler.level = FINESTn" +
"# Limit the message that are printed on the console to FINE and above).n " +
"java.util.logging.ConsoleHandler.level = FINEn" +
"java.util.logging.ConsoleHandler.formatter = net.java.sip.communicator.util.ScLogFormattern";
 ;       
         InputStream in = new ByteArrayInputStream(params.getBytes() );
     ;   try {
       ;     logManager.readConfiguration(in);
        } catch (IOException ex) {
       ;     ex.printStackTrace();
        }
    }
   
    static { checkInitializationParameters(); }
   
  
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )