Package java.util.logging

Examples of java.util.logging.LogManager$LoggerContext


            }
            finally
            {
                // If JULI is used, shut JULI down *after* the server shuts down
                // so log messages aren't lost
                LogManager logManager = LogManager.getLogManager();
                if ( logManager instanceof ClassLoaderLogManager )
                {
                    ( (ClassLoaderLogManager) logManager ).shutdown();
                }
            }
View Full Code Here


        activator.start(context);
       
        if (!Boolean.valueOf(context.getProperty("org.ops4j.pax.logging.skipJUL"))) {
            // ensure PAX's JdkHandler is re-installed after JUL reset
           
            final LogManager manager = LogManager.getLogManager();
            final Handler[] paxHandlers = manager.getLogger("").getHandlers();

            logManagerChangeListener = (new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent evt) {
                    Logger rootLogger = manager.getLogger("");
                    Handler[] handlers = rootLogger.getHandlers();
                    List<Handler> handlerList = (handlers == null) ? Collections.<Handler>emptyList() : Arrays.asList(handlers);                   
                    for (Handler h : paxHandlers) {
                        if (!handlerList.contains(h)) {
                            rootLogger.addHandler(h);
                        }
                    }
                    rootLogger.warning("java.util.logging has been reset by application or component");
                }
            });
           
            manager.addPropertyChangeListener(logManagerChangeListener);
        }
    }
View Full Code Here

    // delete file if it exists
    this.logFile.delete();

    // initialize log framework
    LogManager logManager = LogManager.getLogManager();
    try {
      InputStream ins = ClassLoader.getSystemResourceAsStream(loggerPropertiesFileName);
      // Try the current class loader if system one cannot find the file
      if (ins == null) {
      ins = this.getClass().getClassLoader().getResourceAsStream(loggerPropertiesFileName);
      }
      if (ins != null) {
      logManager.readConfiguration(ins);
      } else {
      System.out.println("WARNING: failed to load "+loggerPropertiesFileName);
      }
    } catch (SecurityException e) {
      handleException(e);
View Full Code Here

import org.apache.metamodel.MetaModelException;

public class JdbcUtilsTest extends TestCase {

  public void testConvertToMetaModelException() throws Exception {
    LogManager logManager = LogManager.getLogManager();
    File logConfigFile = new File("src/test/resources/logconfig.txt");
    assertTrue(logConfigFile.exists());
    logManager.readConfiguration(new FileInputStream(logConfigFile));

    assertTrue(JdbcUtils.wrapException(new SQLException("msg"), "foo") instanceof MetaModelException);
    assertTrue(JdbcUtils.wrapException(
        new SQLException("msg", "sql state"), "foo") instanceof MetaModelException);
    assertTrue(JdbcUtils.wrapException(new SQLException("msg", "sql state",
View Full Code Here


  public void install()
  {
    // Make sure the LogManager is fully installed first.
    LogManager lm = LogManager.getLogManager();

    SecurityManager oldsm = System.getSecurityManager();
   
    if (oldsm == this)
      throw new IllegalStateException("already installed");
View Full Code Here


  public void install()
  {
    // Make sure the LogManager is fully installed first.
    LogManager lm = LogManager.getLogManager();

    SecurityManager oldsm = System.getSecurityManager();
   
    if (oldsm == this)
      throw new IllegalStateException("already installed");
View Full Code Here

     * Keep LOGGING_LOOP_COUNT console.* files around
     */
    protected void configureLogging()
    {
        // Read configuration from specified file or default resource
        LogManager lm = LogManager.getLogManager();
        String fname = System.getProperty(KEY_LOGGING_CONFIG_FILE);

        boolean inited = false;
        if (fname != null && new File(fname).exists())
        {
            try
            {
                // default configuration reader will examine the property and load configuration
                lm.readConfiguration();
                inited = true;
            } catch (IOException e)
            {
                System.err.println(Strings.error("logging.using.overriden.configuration.errored"));
                e.printStackTrace();
            }
        }

        // If configuration still not read use internal production configuration
        if (!inited)
        {
            final InputStream url =
                this.getClass().getClassLoader().getResourceAsStream(RESOURCE_LOGGING_PROPERTIES);
            try
            {
                lm.readConfiguration(url);
            } catch (IOException e)
            {
                System.err.println(Strings.error("logging.unable.to.use.production.configuration"));
                e.printStackTrace();
            }
View Full Code Here

            return;
        }
        InputStream istream = null;

        try {
            LogManager lm = LogManager.getLogManager();
            String path =
                "/org/hsqldb/resources/jdklogging-default.properties";

            if (isDefaultJdkConfig()) {
                lm.reset();

                ConsoleHandler consoleHandler = new ConsoleHandler();

                consoleHandler.setFormatter(
                    new BasicTextJdkLogFormatter(false));
                consoleHandler.setLevel(Level.INFO);
                istream = FrameworkLogger.class.getResourceAsStream(path);
                lm.readConfiguration(istream);

                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

        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;
View Full Code Here

            Runtime.getRuntime().addShutdownHook(shutdownHook);

            // If JULI is being used, disable JULI's shutdown hook since
            // shutdown hooks run in parallel and log messages may be lost
            // if JULI's hook completes before the CatalinaShutdownHook()
            LogManager logManager = LogManager.getLogManager();
            if (logManager instanceof ClassLoaderLogManager) {
                ((ClassLoaderLogManager) logManager).setUseShutdownHook(
                        false);
            }
        }
View Full Code Here

TOP

Related Classes of java.util.logging.LogManager$LoggerContext

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.