/** * Set Level. Ignore OFF - and higher then FINE * * @see java.util.logging.Handler#setLevel(java.util.logging.Level) * @param newLevel ignored * @throws java.lang.SecurityException */ public synchronized void setLevel(Level newLevel) throws SecurityException { if (newLevel == null) return; if (newLevel == Level.OFF) super.setLevel(Level.SEVERE); else if (newLevel == Level.ALL || newLevel == Level.FINEST || newLevel == Level.FINER) super.setLevel(Level.FINE); else super.setLevel(newLevel); } // SetLevel
/** * Set up a pair of Handlers for jOVAL system logging events, one logging to the specified logFile * and the other to the console, at the indicated logging level, and return a Logger configured to * use them. */ public static Logger createDuplex(File logFile, Level level) throws IOException { Handler logfileHandler = new FileHandler(logFile.getPath(), false); logfileHandler.setFormatter(new LogFormatter(Type.FILE)); logfileHandler.setLevel(level); Handler consoleHandler = new ConsoleHandler(); consoleHandler.setFormatter(new LogFormatter(Type.CONSOLE)); consoleHandler.setLevel(level); Logger logger = Logger.getLogger(JOVALMsg.getLogger().getName()); logger.setLevel(level); logger.addHandler(logfileHandler); logger.addHandler(consoleHandler); return logger; }
private static void setLevel(final Level level) { LOGGER.setLevel(level); for (final Handler each : LOGGER.getHandlers()) { each.setLevel(level); } }
private void setupLogging() throws IOException { System.out.println("Setting up logging..."); Level level = LogHelper.getLogLevel(m_testData.getLogLevel()); if (level == null) { System.err.println("No such log level and will use Level.INFO instead"); level = Level.INFO; } fh = new FileHandler(m_testData.getLogFile(), false); // have to change the log level of the handler to let log come out as designed fh.setLevel(level); // change the formatter from default xml to simple text fh.setFormatter(new SimpleFormatter()); theLogger.setLevel(level); theLogger.addHandler(fh); // close the Console handler so that we only need log in file Handler[] handlers = Logger.getLogger("").getHandlers(); for (Handler handler : handlers) { if (handler instanceof ConsoleHandler) { handler.setLevel(Level.OFF); break; } } }
protected static void setupSidlogger(Level lvl) { if (!Level.OFF.equals(lvl)) { Filter bslf = new BoshSidLoggerFilter(); Logger BoshConnectionManagerLogger = Logger.getLogger(BoshConnectionManager.class.getName()); Logger BoshSessionLogger = Logger.getLogger(BoshSession.class.getName()); if (BoshConnectionManagerLogger.getLevel() == null || BoshSessionLogger.getLevel() == null || BoshConnectionManagerLogger.getLevel().intValue() < lvl.intValue()) { BoshConnectionManagerLogger.setLevel(lvl); BoshConnectionManagerLogger.setFilter(bslf); BoshSessionLogger.setLevel(lvl); BoshSessionLogger.setFilter(bslf); BoshConnectionManagerLogger.getParent().setFilter(bslf); } try { if (null == sidFilehandler) { sidFilehandler = new FileHandler("logs/bosh_sid.log", 10000000, 5, false); sidFilehandler.setLevel(lvl); sidFilehandler.setFilter(bslf); BoshConnectionManagerLogger.getParent().addHandler(sidFilehandler); } } catch (IOException ex) { log.log(Level.CONFIG, "Error creating BOSH SID logger" + ex); } } }
@Override public void setLevelOfAllHandler(final Level newLevel) throws SecurityException { final Handler[] hs = getHandlers(); for (final Handler h : hs) { h.setLevel(newLevel); } }
///////////////////////// non-public below ////////////////////////////// static synchronized void setConsoleLevel(Level level) { for (Handler h : logger.getHandlers()) { if (ConsoleHandler.class.isAssignableFrom(h.getClass())) { h.setLevel(level); } } }
public void setLevel(Level level) { LogService.getRoot().setLevel(level); handler.setLevel(level); ParameterService.setParameterValue( MainFrame.PROPERTY_RAPIDMINER_GUI_LOG_LEVEL, level.getName()); ParameterService.saveParameters(); }
private static void setBenchmarkConfiguration(int udp_sender, int udp_receiver, boolean verbose) { if (verbose) { Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).setLevel(Level.ALL); for (Handler h : Logger.getLogger("").getHandlers()) h.setLevel(Level.ALL); Logger.getLogger(UDPConnector.class.toString()).setLevel(Level.ALL); } else { Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).setLevel(Level.SEVERE); Logger.getLogger("").setLevel(Level.SEVERE); } // Network configuration optimal for performance benchmarks NetworkConfig.createStandardWithoutFile() // Disable deduplication OR strongly reduce lifetime .setString(NetworkConfigDefaults.DEDUPLICATOR, NetworkConfigDefaults.NO_DEDUPLICATOR) .setInt(NetworkConfigDefaults.EXCHANGE_LIFECYCLE, 1500) .setInt(NetworkConfigDefaults.MARK_AND_SWEEP_INTERVAL, 2000) // Increase buffer for network interface to 10 MB .setInt(NetworkConfigDefaults.UDP_CONNECTOR_RECEIVE_BUFFER, 10 * 1024 * 1024) .setInt(NetworkConfigDefaults.UDP_CONNECTOR_SEND_BUFFER, 10 * 1024 * 1024) // Increase threads for receiving and sending packets through the socket .setInt(NetworkConfigDefaults.UDP_CONNECTOR_RECEIVER_THREAD_COUNT, udp_receiver) .setInt(NetworkConfigDefaults.UDP_CONNECTOR_SENDER_THREAD_COUNT, udp_sender) // Disable message logging .setBoolean(NetworkConfigDefaults.UDP_CONNECTOR_LOG_PACKETS, verbose); }
@Before public void setUp() { // 设置logger Logger logger = Logger.getLogger("wyq.toolbox.di"); Handler h = new ConsoleHandler(); h.setLevel(Level.ALL); logger.addHandler(h); logger.setLevel(Level.FINE); // set FINER to see tracing logs }
private static void configureLogging() { final Handler[] handlers = Logger.getLogger("").getHandlers(); for (final Handler handler : handlers) { handler.setLevel(Level.ALL); } Engine.getLogger().setLevel(Level.ALL); YahooParser.logger.setLevel(Level.ALL); }
/** Initialize */ private void initialize() { // System.out.println("CLogConsole.initialize"); // Formatting setFormatter(CLogFormatter.get()); // Default Level super.setLevel(Level.INFO); // Filter setFilter(CLogFilter.get()); } // initialize
/** * Overidden to ensure changes to the Level for this logger are forwarded to the ErosHandler. * * @param newLevel The new logging level. * @throws SecurityException * @see Logger#setLevel(Level) */ public void setLevel(Level newLevel) throws SecurityException { super.setLevel(newLevel); Handler[] handlers = this.getHandlers(); for (int i = 0; i < handlers.length; i++) { Handler handler = handlers[i]; if (handler instanceof ErosHandler) { handler.setLevel(newLevel); } } }
/** * Sets the level of all muCommander loggers, namely {@link AppLogger}, {@link FileLogger} and * {@link CommonsLogger}. * * @param level the new log level */ public static void updateLogLevel(Level level) { // Set the level of muCommander loggers. // Note: non-muCommander loggers default to the level defined in the JRE's logging.properties. CommonsLogger.getLogger().setLevel(level); FileLogger.getLogger().setLevel(level); AppLogger.getLogger().setLevel(level); Logger rootLogger = LogManager.getLogManager().getLogger(""); Handler handlers[] = rootLogger.getHandlers(); for (Handler handler : handlers) handler.setLevel(level); }
protected static void setFileHandlerLevel(Handler handler, Level newLevel) { if (handler instanceof FileHandler) { handler.setLevel(newLevel); } else if (handler instanceof CompositeHandler) { setFileHandlerLevel(((CompositeHandler) handler).getHandlers(), newLevel); } else if (handler instanceof DelegatingHandler) { setFileHandlerLevel(((DelegatingHandler) handler).getBaseHandler(), newLevel); } else { // } }
static { if ((System.getProperty("java.util.logging.config.file") == null) && (System.getProperty("java.util.logging.config.class") == null)) { LOGGER.setUseParentHandlers(false); final Handler handler = new ConsoleHandler(); handler.setFormatter(new PlainFormatter()); addOrSetHandler(handler); LOGGER.setLevel(Level.INFO); handler.setLevel(Level.ALL); } }
static { HANDLER = new StreamHandler( System.out, new Formatter() { public String format(LogRecord record) { return String.format( "[Guice %s] %s%n", record.getLevel().getName(), record.getMessage()); } }); HANDLER.setLevel(Level.ALL); }
private static void setVlog(Logger logger, LogLevel logLevel) { final Level newLevel = logLevel.getLevel(); logger.setLevel(newLevel); do { for (Handler handler : logger.getHandlers()) { Level handlerLevel = handler.getLevel(); if (newLevel.intValue() < handlerLevel.intValue()) { handler.setLevel(newLevel); } } } while (logger.getUseParentHandlers() && (logger = logger.getParent()) != null); }
public Handler addLogConsoleHandler(Level l) { if (l == null) { return addLogConsoleHandler(Level.ALL); } // Create and set handler Handler systemOut = new ConsoleHandler(); systemOut.setLevel(l); getLogger().addHandler(systemOut); getLogger().setLevel(l); // Prevent logs from processed by default Console handler. getLogger().setUseParentHandlers(false); // Solution 1 return systemOut; }
/** * Initialization of the task. * * @throws BuildException in case an error occured */ @Override public void init() throws BuildException { Logger baselogger = Logger.getLogger("org.cesta"); baselogger.setLevel(Level.ALL); // we want to disable other handlers and pass everything to Ant for (Handler h : baselogger.getHandlers()) baselogger.removeHandler(h); // create TaskLogHandler, which forwards all messages to Ant logging subsystem Handler handler = new TaskLogHandler(this); handler.setFormatter(new TaskLogFormatter()); handler.setLevel(Level.ALL); baselogger.addHandler(handler); }
void initialize() { // set this as a top level logger, to control console level logger = Logger.getLogger("com.jaivox.util.Log"); logger.setUseParentHandlers(false); Handler hConsole = new ConsoleHandler(); hConsole.setFormatter(new Logformat()); hConsole.setLevel(Level.FINEST); logger.addHandler(hConsole); logger.setLevel(Level.FINEST); // what is the level of this logger? String s = logger.getLevel().toString(); System.out.println("Logger log level after creating " + s); initialized = true; }
private static void configureLogging(CommandLineOptionHelper helper) { Level logLevel = helper.isParamPresent("-debug") ? Level.FINE : LoggingOptions.getDefaultLogLevel(); if (logLevel == null) { logLevel = Level.INFO; } Logger.getLogger("").setLevel(logLevel); Logger.getLogger("org.openqa.jetty").setLevel(Level.WARNING); String logFilename = helper.isParamPresent("-log") ? helper.getParamValue("-log") : LoggingOptions.getDefaultLogOutFile(); if (logFilename != null) { for (Handler handler : Logger.getLogger("").getHandlers()) { if (handler instanceof ConsoleHandler) { Logger.getLogger("").removeHandler(handler); } } try { Handler logFile = new FileHandler(new File(logFilename).getAbsolutePath(), true); logFile.setFormatter(new TerseFormatter(true)); logFile.setLevel(logLevel); Logger.getLogger("").addHandler(logFile); } catch (IOException e) { throw new RuntimeException(e); } } else { boolean logLongForm = helper.isParamPresent("-logLongForm"); for (Handler handler : Logger.getLogger("").getHandlers()) { if (handler instanceof ConsoleHandler) { handler.setLevel(logLevel); handler.setFormatter(new TerseFormatter(logLongForm)); } } } }
static { try { final Level level = Level.parse(System.getProperty(getLoggerName(), "WARNING")); final Handler[] handlers = Logger.getLogger("").getHandlers(); for (final Handler handler : handlers) { handler.setLevel(level); } logger.setLevel(level); } catch (final Exception e) { System.out.println("Exception " + e + " in Aparapi logging setup"); e.printStackTrace(); } };
/** * Sets the application-wide log level. * * @param logLevel Log level to set */ public static void setApplicationLogLevel(final Level logLevel) { final LogManager logManager = LogManager.getLogManager(); final List<String> loggerNames = Collections.list(logManager.getLoggerNames()); for (final String loggerName : loggerNames) { final Logger logger = logManager.getLogger(loggerName); if (logger != null) { logger.setLevel(null); for (final Handler handler : logger.getHandlers()) { handler.setLevel(logLevel); } } } final Logger rootLogger = Logger.getLogger(""); rootLogger.setLevel(logLevel); }
private static void setConsoleHandler(Logger logger, boolean removeOtherHandlers) { Handler consoleHandler = null; for (Handler h : logger.getHandlers()) { if (h instanceof ConsoleHandler) { consoleHandler = h; } else if (removeOtherHandlers) { logger.removeHandler(h); } } if (consoleHandler == null) { consoleHandler = new ConsoleHandler(); logger.addHandler(new ConsoleHandler()); } consoleHandler.setLevel(Level.ALL); consoleHandler.setFilter(null); }
public static void setGlobalLogLevel(Level targetLogLevel) { for (Enumeration<String> loggerNames = LogManager.getLogManager().getLoggerNames(); loggerNames.hasMoreElements(); ) { String loggerName = loggerNames.nextElement(); Logger logger = LogManager.getLogManager().getLogger(loggerName); if (logger != null) { logger.setLevel(targetLogLevel); } } for (Handler handler : Logger.getLogger("").getHandlers()) { handler.setLevel(targetLogLevel); } Logger.getLogger("").setLevel(targetLogLevel); }
/** * Force logger to a new level. * * @param level TRACE,DEBUG,INFO,WARN,ERROR,FATAL */ public static void setUp(String level) { if (forceJuli || log4j == null) { Logger.juli.setLevel(toJuliLevel(level)); } else { Logger.log4j.setLevel(org.apache.log4j.Level.toLevel(level)); if (redirectJuli) { java.util.logging.Logger rootLogger = java.util.logging.Logger.getLogger(""); for (Handler handler : rootLogger.getHandlers()) { rootLogger.removeHandler(handler); } Handler activeHandler = new JuliToLog4jHandler(); java.util.logging.Level juliLevel = toJuliLevel(level); activeHandler.setLevel(juliLevel); rootLogger.addHandler(activeHandler); rootLogger.setLevel(juliLevel); } } }
public static synchronized LocalOnlyAcsLogger getInstance(String namespace, Level level) { if (instance == null) { LogConfig testLogConfig = new LogConfig(); testLogConfig.setDefaultMinLogLevelLocal(AcsLogLevel.getNativeLevel(level).getAcsLevel()); instance = new LocalOnlyAcsLogger(namespace, testLogConfig); instance.setUseParentHandlers(false); Handler logHandler = new StdOutConsoleHandler(testLogConfig, namespace, null); logHandler.setFormatter( new AcsXMLLogFormatter() { public String format(LogRecord lr) { String xml = super.format(lr); return xml + '\n'; } }); logHandler.setLevel(level); instance.addHandler(logHandler); } return instance; }
/** * Set the logging level. The levels in descending order are:<br> * * <ul> * <li>ALL * <li>SEVERE (highest value) * <li>WARNING * <li>INFO * <li>CONFIG * <li>FINE * <li>FINER * <li>FINEST (lowest value) * <li>OFF * </ul> * * @param logLevel one of the valid log levels according to {@link Level#parse(String)} */ public static void setLogLevel(String logLevel) { Level level; try { level = Level.parse(logLevel.toUpperCase()); } catch (IllegalArgumentException e) { LOG.warning( () -> "Invalid log level %s. Must be one of OFF, SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST or ALL."); return; } Logger root = Logger.getLogger(Main.class.getPackage().getName()); root.setLevel(level); for (Handler handler : root.getHandlers()) { handler.setLevel(level); } }
@Override public synchronized void start(final StartContext context) throws StartException { final Handler handler; final ModuleLoader moduleLoader = Module.forClass(CustomHandlerService.class).getModuleLoader(); final ModuleIdentifier id = ModuleIdentifier.create(moduleName); try { final Class<?> handlerClass = Class.forName(className, false, moduleLoader.loadModule(id).getClassLoader()); if (Handler.class.isAssignableFrom(handlerClass)) { handler = (Handler) handlerClass.newInstance(); } else { throw new StartException( String.format( "%s %s is not a valid %s.", CUSTOM_HANDLER, className, Handler.class.getName())); } } catch (ClassNotFoundException e) { throw new StartException(e); } catch (ModuleLoadException e) { throw new StartException( String.format( "%s %s is not a valid %s.", CUSTOM_HANDLER, className, Handler.class.getName()), e); } catch (InstantiationException e) { throw new StartException( String.format( "%s %s is not a valid %s.", CUSTOM_HANDLER, className, Handler.class.getName()), e); } catch (IllegalAccessException e) { throw new StartException( String.format( "%s %s is not a valid %s.", CUSTOM_HANDLER, className, Handler.class.getName()), e); } formatterSpec.apply(handler); if (level != null) handler.setLevel(level); try { handler.setEncoding(encoding); } catch (UnsupportedEncodingException e) { throw new StartException(e); } value = handler; }