Package java.util.logging

Examples of java.util.logging.LogManager


         "Global", "Can't find java.util.logging.config.file=logging.properties");
      }
      try {
         InputStream in = url.openStream();

         LogManager logManager = LogManager.getLogManager();
         logManager.readConfiguration(in);
         in.close();

         // init from command line (or xmlBlaster.properties)
         synchronized (Global.class) {
            if (!logIsInitialized) {
               Map map = this.property.getPropertiesForContextNode(this.contextNode, ContextNode.LOGGING_MARKER_TAG, "__default");
               String defVal = (String)map.get("__default");
               if (defVal != null) {
                  try {
                     Level defaultLevel = Level.parse(defVal);
                     Logger defLogger = logManager.getLogger("");
                     if (defLogger != null) {
                        defLogger.setLevel(defaultLevel);
                        log.info("Setting default log level to '" + defaultLevel.getName() + "'");
                     }
                     else
                        log.warning("Setting default log level to '" + defaultLevel.getName() + "' failed since default log level is null");
                  }
                  catch (Throwable ex) {
                     log.warning("An exception occured when parsing '" + defVal + "' as a log level");
                  }
               }
               Iterator iter = map.entrySet().iterator();

               Logger defLogger = logManager.getLogger("");
               // Handler[] tmpHandlers = defLogger.getHandlers();
               // Handler[] refHandlers = new Handler[tmpHandlers.length];
               Handler[] refHandlers = defLogger.getHandlers();
               for (int i=0; i < refHandlers.length; i++) {
                  refHandlers[i].setLevel(Level.FINEST);
View Full Code Here


  /**
   * Apply the logging configuration to the current loggers
   * Can be called several times in case new classes are loaded
   */
  public void apply(){
    LogManager lm=LogManager.getLogManager();
        if(lowestLevel != null){
            for(Iterator handlerIterator = outHandlerList.iterator(); handlerIterator.hasNext();){
                Handler outHandler = (Handler) handlerIterator.next();
                outHandler.setLevel(lowestLevel);
            }
        }
    Enumeration e=lm.getLoggerNames();
    while(e.hasMoreElements()){
      Logger l=lm.getLogger((String)e.nextElement());
      apply(l);
    }
  }
View Full Code Here

    return url.substring(0, endIndex);
  }
 
  private Map<String, Level> getLoggers() {
    Map<String, Level> result = new HashMap<String, Level>();
    LogManager logManager = LogManager.getLogManager();
    Enumeration loggerNames = logManager.getLoggerNames();
    while ( loggerNames.hasMoreElements() ){
      String loggerName = (String)loggerNames.nextElement();
      Logger logger = logManager.getLogger(loggerName);
      result.put(loggerName, logger.getLevel());
    }
    return sortMap(result);
  }
View Full Code Here

            command.execute();
        }
    }

    private static void setLogging(Command command){
        LogManager logManager = LogManager.getLogManager();
        logManager.reset();
        /* set the log level on the root logger */
        Logger rootLogger = Logger.getLogger("");
        rootLogger.setLevel(command.getLogLevel());
        ConsoleHandler consoleHandler = new ConsoleHandler();
        consoleHandler.setLevel(command.getLogLevel());
View Full Code Here

   
    /**
     * Get any configuration properties set
     */
    private void configure() {
        final LogManager manager = LogManager.getLogManager();
        final String className = getClass().getName();
       
        final String level = manager.getProperty(className + ".level");
        setLevel((level == null) ? Level.INFO : Level.parse(level));
       
        final Level levelStdOut = parseLevel(manager.getProperty(className + ".levelStdOut"));
        final Level levelSplit = parseLevel(manager.getProperty(className + ".levelSplit"));
        final Level levelStdErr = parseLevel(manager.getProperty(className + ".levelStdErr"));
        setLevels(levelStdOut,levelSplit,levelStdErr);
       
        final String filter = manager.getProperty(className + ".filter");
        setFilter(makeFilter(filter));
       
        final String formatter = manager.getProperty(className + ".formatter");
        setFormatter(makeFormatter(formatter));
       
        final String encoding = manager.getProperty(className + ".encoding");
        try {
            this.stdOutHandler.setEncoding(encoding);
            this.stdErrHandler.setEncoding(encoding);
        } catch (final UnsupportedEncodingException e) {
            Log.logException(e);
        }
       
        final String ignoreCtrlChrStr = manager.getProperty(className + ".ignoreCtrlChr");
        this.ignoreCtrlChr = (ignoreCtrlChrStr==null) ? false : "true".equalsIgnoreCase(ignoreCtrlChrStr);
       
    }   
View Full Code Here

        try {
            System.out.println("STARTUP: Trying to load logging configuration from file " + loggingConfigFile.toString());
            fileIn = new FileInputStream(loggingConfigFile);

            // loading the logger configuration from file
            final LogManager logManager = LogManager.getLogManager();
            logManager.readConfiguration(fileIn);

            // creating the logging directory
            String logPattern = logManager.getProperty("java.util.logging.FileHandler.pattern");
            int stripPos = logPattern.lastIndexOf(File.separatorChar);
            if (!new File(logPattern).isAbsolute()) logPattern = new File(dataPath, logPattern).getAbsolutePath();
            if (stripPos < 0) stripPos = logPattern.lastIndexOf(File.separatorChar);
            File log = new File(logPattern.substring(0, stripPos));
            if (!log.isAbsolute()) log = new File(dataPath, log.getPath());
View Full Code Here

   
    /**
     * Get any configuration properties set
     */
    private void configure() {
        final LogManager manager = LogManager.getLogManager();
        final String className = getClass().getName();
       
        final String level = manager.getProperty(className + ".level");
        setLevel((level == null) ? Level.INFO : Level.parse(level));
       
        final String filter = manager.getProperty(className + ".filter");
        setFilter(makeFilter(filter));
       
        final String formatter = manager.getProperty(className + ".formatter");
        setFormatter(makeFormatter(formatter));
       
        final String sizeString = manager.getProperty(className + ".size");
        this.size = parseSize(sizeString);
    }   
View Full Code Here

    public static boolean debug;
   
    public LogalizerHandler() {
        super();
       
        final LogManager manager = LogManager.getLogManager();
        final String className = getClass().getName();

        enabled = "true".equalsIgnoreCase(manager.getProperty(className + ".enabled"));
        debug = "true".equalsIgnoreCase(manager.getProperty(className + ".debug"));
    }
View Full Code Here

        }

        if (log4jLoggerClass == null) try {
            log4jGetLogger = null;
            log4jLogMethod = null;
            LogManager lm = LogManager.getLogManager();
            if (haveLoadedOurDefault || isDefaultJdkConfig()) {
                haveLoadedOurDefault = true;
                consoleHandler.setFormatter(
                        new BasicTextJdkLogFormatter(false));
                consoleHandler.setLevel(Level.INFO);
                lm.readConfiguration(
                        FrameworkLogger.class.getResourceAsStream(
                        "/org/hsqldb/resources/jdklogging-default.properties"));
                Logger cmdlineLogger = Logger.getLogger("org.hsqldb.cmdline");
                cmdlineLogger.addHandler(consoleHandler);
                cmdlineLogger.setUseParentHandlers(false);
            } else {
                // Do not intervene.  Use JDK logging exactly as configured by
                // user.
                lm.readConfiguration();
                // The only bad thing about doing this is that if the app has
                // programmatically changed the logging config after starting
                // the program but before using FrameworkLogger, we will
                // clobber those customizations.
            }
View Full Code Here

                "lib/logging.properties");
        if (!globalCfgFile.isFile()) {
            return false;
        }
        FileInputStream fis = null;
        LogManager lm = LogManager.getLogManager();
        try {
            fis = new FileInputStream(globalCfgFile);
            Properties defaultProps = new Properties();
            defaultProps.load(fis);
            Enumeration names = defaultProps.propertyNames();
            int i = 0;
            String name;
            String liveVal;
            while (names.hasMoreElements()) {
                i++;
                name = (String) names.nextElement();
                liveVal = lm.getProperty(name);
                if (liveVal == null) {
                    return false;
                }
                if (!lm.getProperty(name).equals(liveVal)) {
                    return false;
                }
            }
            return true;
        } catch (IOException ioe) {
View Full Code Here

TOP

Related Classes of java.util.logging.LogManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.