List of usage examples for java.util.logging LogManager getLogManager
public static LogManager getLogManager()
From source file:com.coinblesk.payments.WalletService.java
private void initLogging() { LogManager.getLogManager().getLogger("").setLevel(Constants.JAVA_LOGGER_LEVEL); ((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME)) .setLevel(Constants.LOGBACK_LOGGER_LEVEL); }
From source file:org.jacorb.JacorbActivator.java
/** * This method ensures that if the Java logging properties weren't properly installed by the IDE's feature * into the configuration directory that we'll load a backup. This is primarily important for debugging the IDE * within Eclipse where this is the situation. * /* www .j av a 2 s. c o m*/ * @param context */ private void configureJavaLogger(final BundleContext context) { String currentProperty = System.getProperty("java.util.logging.config.file"); if (currentProperty != null) { File propFile = new File(currentProperty); if (propFile.exists()) { try { LogManager.getLogManager().readConfiguration(); return; } catch (SecurityException e) { e.printStackTrace(); // SUPPRESS CHECKSTYLE SHUTDOWN MESSAGE } catch (IOException e) { e.printStackTrace(); // SUPPRESS CHECKSTYLE SHUTDOWN MESSAGE } } } InputStream test = null; InputStream logInputStream = null; try { test = Platform.getConfigurationLocation().getDataArea("javalogger.properties").openStream(); LogManager.getLogManager().readConfiguration(test); } catch (IOException e) { URL javaloggerURL = FileLocator.find(context.getBundle(), new Path("etc/javalogger.properties"), null); if (javaloggerURL != null) { try { logInputStream = javaloggerURL.openStream(); LogManager.getLogManager().readConfiguration(logInputStream); } catch (IOException e2) { e.printStackTrace(); // SUPPRESS CHECKSTYLE SHUTDOWN MESSAGE } catch (SecurityException e2) { e.printStackTrace(); // SUPPRESS CHECKSTYLE SHUTDOWN MESSAGE } } } finally { if (test != null) { try { test.close(); } catch (IOException e) { // PASS } } if (logInputStream != null) { try { logInputStream.close(); } catch (IOException e) { // PASS } } } }
From source file:com.kylinolap.query.test.KylinTestBase.java
protected int runSQL(File sqlFile, boolean debug, boolean explain) throws Exception { if (debug) {//from w w w . j a v a 2s . c o m System.setProperty("optiq.debug", "true"); InputStream inputStream = new FileInputStream("src/test/resources/logging.properties"); LogManager.getLogManager().readConfiguration(inputStream); } String queryName = StringUtils.split(sqlFile.getName(), '.')[0]; printInfo("Testing Query " + queryName); String sql = getTextFromFile(sqlFile); if (explain) { sql = "explain plan for " + sql; } int count = executeQuery(sql, true); if (debug) { System.clearProperty("optiq.debug"); } return count; }
From source file:org.apache.kylin.query.test.KylinTestBase.java
protected int runSQL(File sqlFile, boolean debug, boolean explain) throws Exception { if (debug) {//w w w. jav a 2 s . co m System.setProperty("calcite.debug", "true"); InputStream inputStream = new FileInputStream("src/test/resources/logging.properties"); LogManager.getLogManager().readConfiguration(inputStream); } String queryName = StringUtils.split(sqlFile.getName(), '.')[0]; printInfo("Testing Query " + queryName); String sql = getTextFromFile(sqlFile); if (explain) { sql = "explain plan for " + sql; } int count = executeQuery(sql, true); if (debug) { System.clearProperty("optiq.debug"); } return count; }
From source file:NewApplication.java
/** * @param args the command line arguments *//*from w w w . ja va 2s . c o m*/ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(NewApplication.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(NewApplication.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(NewApplication.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(NewApplication.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> Logger log = Logger.getLogger("NewApplication"); try { FileInputStream fis = new FileInputStream("p.properties"); LogManager.getLogManager().readConfiguration(fis); log.setLevel(Level.FINE); log.addHandler(new java.util.logging.ConsoleHandler()); log.setUseParentHandlers(false); log.info("starting NewApplication"); fis.close(); } catch (Exception e) { } ; /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new NewApplication().setVisible(true); } }); }
From source file:brut.apktool.Main.java
private static void setupLogging(Verbosity verbosity) { Logger logger = Logger.getLogger(""); for (Handler handler : logger.getHandlers()) { logger.removeHandler(handler);/*from w w w. j a v a 2 s.co m*/ } LogManager.getLogManager().reset(); if (verbosity == Verbosity.QUIET) { return; } Handler handler = new Handler() { @Override public void publish(LogRecord record) { if (getFormatter() == null) { setFormatter(new SimpleFormatter()); } try { String message = getFormatter().format(record); if (record.getLevel().intValue() >= Level.WARNING.intValue()) { System.err.write(message.getBytes()); } else { System.out.write(message.getBytes()); } } catch (Exception exception) { reportError(null, exception, ErrorManager.FORMAT_FAILURE); } } @Override public void close() throws SecurityException { } @Override public void flush() { } }; logger.addHandler(handler); if (verbosity == Verbosity.VERBOSE) { handler.setLevel(Level.ALL); logger.setLevel(Level.ALL); } else { handler.setFormatter(new Formatter() { @Override public String format(LogRecord record) { return record.getLevel().toString().charAt(0) + ": " + record.getMessage() + System.getProperty("line.separator"); } }); } }
From source file:org.callimachusproject.repository.CalliRepository.java
private void setLoggerLevel(String fragment, Level level) { boolean found = false; Enumeration<String> names = LogManager.getLogManager().getLoggerNames(); while (names.hasMoreElements()) { String name = names.nextElement(); if (name.contains(fragment)) { Logger logger = Logger.getLogger(name); logger.setLevel(level);/* www .j ava 2 s . co m*/ setHandlerLevel(logger, level); found = true; } } if (!found) throw new IllegalArgumentException("No such logger: " + fragment); }
From source file:net.pms.PMS.java
/** * Initialisation procedure for PMS.//from w w w . j a v a 2s . c o m * @return true if the server has been initialized correctly. false if the server could * not be set to listen on the UPnP port. * @throws Exception */ private boolean init() throws Exception { // The public VERSION field is deprecated. // This is a temporary fix for backwards compatibility VERSION = getVersion(); // call this as early as possible displayBanner(); AutoUpdater autoUpdater = null; if (Build.isUpdatable()) { String serverURL = Build.getUpdateServerURL(); autoUpdater = new AutoUpdater(serverURL, getVersion()); } registry = createSystemUtils(); if (!isHeadless()) { frame = new LooksFrame(autoUpdater, configuration); } else { logger.info("GUI environment not available"); logger.info("Switching to console mode"); frame = new DummyFrame(); } /* * we're here: * * main() -> createInstance() -> init() * * which means we haven't created the instance returned by get() * yet, so the frame appender can't access the frame in the * standard way i.e. PMS.get().getFrame(). we solve it by * inverting control ("don't call us; we'll call you") i.e. * we notify the appender when the frame is ready rather than * e.g. making getFrame() static and requiring the frame * appender to poll it. * * XXX an event bus (e.g. MBassador or Guava EventBus * (if they fix the memory-leak issue)) notification * would be cleaner and could support other lifecycle * notifications (see above). */ FrameAppender.setFrame(frame); configuration.addConfigurationListener(new ConfigurationListener() { @Override public void configurationChanged(ConfigurationEvent event) { if ((!event.isBeforeUpdate()) && PmsConfiguration.NEED_RELOAD_FLAGS.contains(event.getPropertyName())) { frame.setReloadable(true); } } }); frame.setStatusCode(0, Messages.getString("PMS.130"), "connect_no-220.png"); RendererConfiguration.loadRendererConfigurations(configuration); logger.info("Checking MPlayer font cache. It can take a minute or so."); checkProcessExistence("MPlayer", true, null, configuration.getMplayerPath(), "dummy"); if (Platform.isWindows()) { checkProcessExistence("MPlayer", true, configuration.getTempFolder(), configuration.getMplayerPath(), "dummy"); } logger.info("Done!"); // check the existence of Vsfilter.dll if (registry.isAvis() && registry.getAvsPluginsDir() != null) { logger.info("Found AviSynth plugins dir: " + registry.getAvsPluginsDir().getAbsolutePath()); File vsFilterdll = new File(registry.getAvsPluginsDir(), "VSFilter.dll"); if (!vsFilterdll.exists()) { logger.info( "VSFilter.dll is not in the AviSynth plugins directory. This can cause problems when trying to play subtitled videos with AviSynth"); } } // Check if VLC is found String vlcVersion = registry.getVlcVersion(); String vlcPath = registry.getVlcPath(); if (vlcVersion != null && vlcPath != null) { logger.info("Found VLC version " + vlcVersion + " at: " + vlcPath); Version vlc = new Version(vlcVersion); Version requiredVersion = new Version("2.0.2"); if (vlc.compareTo(requiredVersion) <= 0) { logger.error("Only VLC versions 2.0.2 and above are supported"); } } // check if Kerio is installed if (registry.isKerioFirewall()) { logger.info("Detected Kerio firewall"); } // force use of specific dvr ms muxer when it's installed in the right place File dvrsMsffmpegmuxer = new File("win32/dvrms/ffmpeg_MPGMUX.exe"); if (dvrsMsffmpegmuxer.exists()) { configuration.setFfmpegAlternativePath(dvrsMsffmpegmuxer.getAbsolutePath()); } // disable jaudiotagger logging LogManager.getLogManager() .readConfiguration(new ByteArrayInputStream("org.jaudiotagger.level=OFF".getBytes())); // wrap System.err System.setErr(new PrintStream(new SystemErrWrapper(), true)); server = new HTTPServer(configuration.getServerPort()); /* * XXX: keep this here (i.e. after registerExtensions and before registerPlayers) so that plugins * can register custom players correctly (e.g. in the GUI) and/or add/replace custom formats * * XXX: if a plugin requires initialization/notification even earlier than * this, then a new external listener implementing a new callback should be added * e.g. StartupListener.registeredExtensions() */ try { ExternalFactory.lookup(); } catch (Exception e) { logger.error("Error loading plugins", e); } // a static block in Player doesn't work (i.e. is called too late). // this must always be called *after* the plugins have loaded. // here's as good a place as any Player.initializeFinalizeTranscoderArgsListeners(); // Initialize a player factory to register all players PlayerFactory.initialize(configuration); // Instantiate listeners that require registered players. ExternalFactory.instantiateLateListeners(); // Any plugin-defined players are now registered, create the GUI view. frame.addEngines(); boolean binding = false; try { binding = server.start(); } catch (BindException b) { logger.info("FATAL ERROR: Unable to bind on port: " + configuration.getServerPort() + ", because: " + b.getMessage()); logger.info("Maybe another process is running or the hostname is wrong."); } new Thread("Connection Checker") { @Override public void run() { try { Thread.sleep(7000); } catch (InterruptedException e) { } if (foundRenderers.isEmpty()) { frame.setStatusCode(0, Messages.getString("PMS.0"), "messagebox_critical-220.png"); } else { frame.setStatusCode(0, Messages.getString("PMS.18"), "apply-220.png"); } } }.start(); if (!binding) { return false; } // initialize the cache if (configuration.getUseCache()) { initializeDatabase(); // XXX: this must be done *before* new MediaLibrary -> new MediaLibraryFolder mediaLibrary = new MediaLibrary(); logger.info("A tiny cache admin interface is available at: http://" + server.getHost() + ":" + server.getPort() + "/console/home"); } // XXX: this must be called: // a) *after* loading plugins i.e. plugins register root folders then RootFolder.discoverChildren adds them // b) *after* mediaLibrary is initialized, if enabled (above) getRootFolder(RendererConfiguration.getDefaultConf()); frame.serverReady(); // UPNPHelper.sendByeBye(); Runtime.getRuntime().addShutdownHook(new Thread("PMS Listeners Stopper") { @Override public void run() { try { for (ExternalListener l : ExternalFactory.getExternalListeners()) { l.shutdown(); } UPNPHelper.shutDownListener(); UPNPHelper.sendByeBye(); logger.debug("Forcing shutdown of all active processes"); for (Process p : currentProcesses) { try { p.exitValue(); } catch (IllegalThreadStateException ise) { logger.trace("Forcing shutdown of process: " + p); ProcessUtil.destroy(p); } } get().getServer().stop(); Thread.sleep(500); } catch (InterruptedException e) { logger.debug("Caught exception", e); } } }); UPNPHelper.sendAlive(); logger.trace("Waiting 250 milliseconds..."); Thread.sleep(250); UPNPHelper.listen(); return true; }
From source file:puma.central.pdp.CentralPUMAPDP.java
private Boolean isLoggingAll() { return !LogManager.getLogManager().getLogger("").getLevel().equals(Level.WARNING); }
From source file:com.brainflow.application.toplevel.Brainflow.java
private void initLogMonitor() { DockableFrame dframe = DockWindowManager.getInstance().createDockableFrame("Log Monitor", "resources/icons/console_view.gif", DockContext.STATE_AUTOHIDE, DockContext.DOCK_SIDE_SOUTH, 1); LogMonitor monitor = new LogMonitor(); monitor.setLevel(Level.FINEST); LogManager.getLogManager().getLogger("").addHandler(monitor); dframe.getContentPane().add(new JScrollPane(monitor.getComponent())); dframe.setPreferredSize(new Dimension(800, 200)); brainFrame.getDockingManager().addFrame(dframe); }