0 Replies Latest reply: Jul 7, 2013 10:55 AM by shivasha RSS

    Log file is not created used util.logger

    shivasha

       

      I need to write a log into a file using java.util.logging.
      File name should read from properties file.

      Issue is file is not created in D:\TestLogging.log

      Below are the configuration:

       

      src\resources\logger.properties

      handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler
      .level=INFO

      java.util.logging.ConsoleHandler.level=SEVERE
      java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter

      java.util.logging.FileHandler.level=ALL

      java.util.logging.FileHandler.pattern=D:\TestLogging.log
      # Number of output files to cycle through, by appending an
      # integer to the base file name:
      java.util.logging.FileHandler.count=1

      # Style of output (Simple or XML):
      java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter

      SimpleLogger.java

      import java.util.logging.*;

      public final class SimpleLogger {

        public static void main(String argv[]) {
        SimpleLogger thing = new SimpleLogger();
        thing.doSomething();
        }

        public void doSomething() {
        fLogger.finest("this is finest");
        fLogger.finer("this is finer");
        fLogger.fine("this is fine");
        fLogger.config("this is config");
        fLogger.info("this is info");
        fLogger.warning("this is a warning");
        fLogger.severe("this is severe");

        fLogger.logp(Level.INFO, this.getClass().toString(), "doSomething", "blah");

        Throwable ex = new IllegalArgumentException("Some exception text");
        fLogger.log(Level.SEVERE, "Some message", ex);
        fLogger.exiting(this.getClass().toString(), "doSomething");
        }
        private static final Logger fLogger =
        Logger.getLogger(SimpleLogger.class.getName());
      }

      Could you please help, any configuration is missed