Java Code Examples for java.util.logging.Level#SEVERE
The following examples show how to use
java.util.logging.Level#SEVERE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogUtilsTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testLogParamsSubstitutionWithThrowable() throws Exception { Logger log = LogUtils.getL7dLogger(LogUtilsTest.class, null, "testLogParamsSubstitutionWithThrowable"); Handler handler = EasyMock.createNiceMock(Handler.class); Exception ex = new Exception(); LogRecord record = new LogRecord(Level.SEVERE, "subbed in 4 & 3"); record.setThrown(ex); EasyMock.reportMatcher(new LogRecordMatcher(record)); handler.publish(record); EasyMock.replay(handler); synchronized (log) { log.addHandler(handler); LogUtils.log(log, Level.SEVERE, "SUB2_MSG", ex, new Object[] {3, 4}); EasyMock.verify(handler); log.removeHandler(handler); } }
Example 2
Source File: ErrorLogHandler.java From beast-mcmc with GNU Lesser General Public License v2.1 | 6 votes |
public void publish(LogRecord record) { super.publish(record); flush(); if (record.getLevel() == Level.SEVERE) { errorCount++; if (errorCount > maxErrorCount) { if (errorCount > 1) { throw new RuntimeException("ErrorLog: Maximum number of errors (" + (maxErrorCount + 1) + ") reached. Terminating BEAST"); } else { throw new RuntimeException("An error was encountered. Terminating BEAST"); } } } }
Example 3
Source File: LogFormatterTest.java From netbeans with Apache License 2.0 | 6 votes |
/** * test whether the result of LogFormatter is the same as XMLFormatter * if there is no nested exception */ public void testXMLFormatterDifference(){ LogRecord rec = new LogRecord(Level.SEVERE, "PROBLEM"); LogFormatter logFormatter = new LogFormatter(); XMLFormatter xmlFormatter = new XMLFormatter(); String logResult = logFormatter.format(rec).replace("1000", "SEVERE"); String xmlResult = xmlFormatter.format(rec); assertEquals("WITHOUT THROWABLE", xmlResult, logResult); rec.setThrown(new NullPointerException("TESTING EXCEPTION")); rec.setResourceBundleName("MUJ BUNDLE"); logResult = logFormatter.format(rec); //remove file names logResult = logResult.replaceAll(" <file>.*</file>\n", "").replace("1000", "SEVERE"); xmlResult = xmlFormatter.format(rec); assertEquals("WITH THROWABLE", xmlResult, logResult); }
Example 4
Source File: CacheLoaderTest.java From blazingcache with Apache License 2.0 | 6 votes |
@Before public void setupLogger() throws Exception { Level level = Level.SEVERE; Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { System.err.println("uncaughtException from thread " + t.getName() + ": " + e); e.printStackTrace(); } }); java.util.logging.LogManager.getLogManager().reset(); ConsoleHandler ch = new ConsoleHandler(); ch.setLevel(level); SimpleFormatter f = new SimpleFormatter(); ch.setFormatter(f); java.util.logging.Logger.getLogger("").setLevel(level); java.util.logging.Logger.getLogger("").addHandler(ch); }
Example 5
Source File: ManagedChannelOrphanWrapper.java From grpc-java with Apache License 2.0 | 6 votes |
@VisibleForTesting static int cleanQueue(ReferenceQueue<ManagedChannelOrphanWrapper> refqueue) { ManagedChannelReference ref; int orphanedChannels = 0; while ((ref = (ManagedChannelReference) refqueue.poll()) != null) { RuntimeException maybeAllocationSite = ref.allocationSite.get(); ref.clearInternal(); // technically the reference is gone already. if (!ref.shutdown.get()) { orphanedChannels++; Level level = Level.SEVERE; if (logger.isLoggable(level)) { String fmt = "*~*~*~ Channel {0} was not shutdown properly!!! ~*~*~*" + System.getProperty("line.separator") + " Make sure to call shutdown()/shutdownNow() and wait " + "until awaitTermination() returns true."; LogRecord lr = new LogRecord(level, fmt); lr.setLoggerName(logger.getName()); lr.setParameters(new Object[] {ref.channelStr}); lr.setThrown(maybeAllocationSite); logger.log(lr); } } } return orphanedChannels; }
Example 6
Source File: SequenceMining.java From sequence-mining with GNU General Public License v3.0 | 6 votes |
@Override public Level convert(final String value) { if (value.equals("SEVERE")) return Level.SEVERE; else if (value.equals("WARNING")) return Level.WARNING; else if (value.equals("INFO")) return Level.INFO; else if (value.equals("CONFIG")) return Level.CONFIG; else if (value.equals("FINE")) return Level.FINE; else if (value.equals("FINER")) return Level.FINER; else if (value.equals("FINEST")) return Level.FINEST; else throw new RuntimeException("Incorrect Log Level."); }
Example 7
Source File: Logging.java From VideoCRE with MIT License | 6 votes |
public static void log(Severity severity, String tag, String message) { if (loggingEnabled) { nativeLog(severity.ordinal(), tag, message); return; } // Fallback to system log. Level level; switch (severity) { case LS_ERROR: level = Level.SEVERE; break; case LS_WARNING: level = Level.WARNING; break; case LS_INFO: level = Level.INFO; break; default: level = Level.FINE; break; } fallbackLogger.log(level, tag + ": " + message); }
Example 8
Source File: NbErrorManager.java From netbeans with Apache License 2.0 | 6 votes |
/** @return the severity of the exception */ Level getSeverity() { if (severity != null) { return severity; } LogRecord[] anns = (arrAll != null) ? arrAll : arr; for (int i = 0; i < anns.length; i++) { Level s = anns[i].getLevel(); if (severity == null || s.intValue() > severity.intValue()) { severity = s; } } if (severity == null || severity == Level.ALL) { // no severity specified, assume this is an error severity = t instanceof Error ? Level.SEVERE : Level.WARNING; } return severity; }
Example 9
Source File: ErrorManager.java From netbeans with Apache License 2.0 | 6 votes |
private static Level convertSeverity(final int severity, boolean forException, Level def) { Level sev = def; if (severity >= ERROR) { sev = Level.SEVERE; } else if (severity >= EXCEPTION) { sev = Level.SEVERE; } else if (severity >= USER) { sev = OwnLevel.USER; } else if (severity >= WARNING) { sev = Level.WARNING; } else if (severity >= INFORMATIONAL) { sev = forException ? Level.INFO: Level.FINE; } return sev; }
Example 10
Source File: LogLevelMapping.java From selenium with Apache License 2.0 | 5 votes |
/** * Normalizes the given level to one of those supported by Selenium. * * @param level log level to normalize * @return the selenium supported corresponding log level */ public static Level normalize(Level level) { if (levelMap.containsKey(level.intValue())) { return levelMap.get(level.intValue()); } else if (level.intValue() >= Level.SEVERE.intValue()) { return Level.SEVERE; } else if (level.intValue() >= Level.WARNING.intValue()) { return Level.WARNING; } else if (level.intValue() >= Level.INFO.intValue()) { return Level.INFO; } else { return Level.FINE; } }
Example 11
Source File: RoboconfLogFormatter.java From roboconf-platform with Apache License 2.0 | 5 votes |
/** * @return the maximum length of a log level */ static int findMaxLevelLength() { Level[] levels = new Level[] { Level.ALL, Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.INFO, Level.OFF, Level.SEVERE, Level.WARNING }; int result = -1; for( Level level : levels ) result = Math.max( result, level.toString().length()); return result; }
Example 12
Source File: LogbackUtil.java From otroslogviewer with Apache License 2.0 | 5 votes |
public static Level convertLevel(ch.qos.logback.classic.Level level) { if (ch.qos.logback.classic.Level.DEBUG_INT == level.toInt()) { return Level.FINE; } else if (ch.qos.logback.classic.Level.TRACE_INT == level.toInt()) { return Level.FINEST; } else if (ch.qos.logback.classic.Level.INFO_INT == level.toInt()) { return Level.INFO; } else if (ch.qos.logback.classic.Level.WARN_INT == level.toInt()) { return Level.WARNING; } else if (ch.qos.logback.classic.Level.ERROR_INT == level.toInt()) { return Level.SEVERE; } return Level.INFO; }
Example 13
Source File: JdkLoggingImpl.java From mybatis-generator-plus with Apache License 2.0 | 5 votes |
public void error(String s, Throwable e) { LogRecord lr = new LogRecord(Level.SEVERE, s); lr.setSourceClassName(log.getName()); lr.setThrown(e); log.log(lr); }
Example 14
Source File: LogRecordsTest.java From netbeans with Apache License 2.0 | 5 votes |
private static Level randomLevel(Random r) { int lev = r.nextInt(1100); if (lev >= Level.SEVERE.intValue()) return Level.SEVERE; if (lev >= Level.WARNING.intValue()) return Level.WARNING; if (lev >= Level.INFO.intValue()) return Level.INFO; if (lev >= Level.CONFIG.intValue()) return Level.CONFIG; if (lev >= Level.FINE.intValue()) return Level.FINE; if (lev >= Level.FINER.intValue()) return Level.FINER; if (lev >= Level.FINEST.intValue()) return Level.FINEST; return Level.OFF; }
Example 15
Source File: ClientSharedUtils.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
public static void initLog4J(String logFile, Level level) throws IOException { // set the log file location Properties props = new Properties(); InputStream in = ClientSharedUtils.class.getResourceAsStream( "/store-log4j.properties"); try { props.load(in); } finally { in.close(); } // override file location and level if (level != null) { String levelStr = "INFO"; // convert to log4j level if (level == Level.SEVERE) { levelStr = "ERROR"; } else if (level == Level.WARNING) { levelStr = "WARN"; } else if (level == Level.INFO || level == Level.CONFIG) { levelStr = "INFO"; } else if (level == Level.FINE || level == Level.FINER || level == Level.FINEST) { levelStr = "TRACE"; } else if (level == Level.ALL) { levelStr = "DEBUG"; } else if (level == Level.OFF) { levelStr = "OFF"; } if (logFile != null) { props.setProperty("log4j.rootCategory", levelStr + ", file"); } else { props.setProperty("log4j.rootCategory", levelStr + ", console"); } } if (logFile != null) { props.setProperty("log4j.appender.file.file", logFile); } // lastly override with any user provided properties file in = ClientSharedUtils.class.getResourceAsStream("/log4j.properties"); if (in != null) { Properties setProps = new Properties(); try { setProps.load(in); } finally { in.close(); } props.putAll(setProps); } LogManager.resetConfiguration(); PropertyConfigurator.configure(props); }
Example 16
Source File: ReportRunner.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * new a EngineConfig and config it with user's setting * */ protected EngineConfig createEngineConfig( ) { EngineConfig config = new EngineConfig( ); String resourcePath = (String) params.get( "resourceDir" ); if ( resourcePath != null ) config.setResourcePath( resourcePath.trim( ) ); String tempDir = (String) params.get( "tempDir" ); if ( tempDir != null ) config.setTempDir( tempDir.trim() ); String logDir = (String) params.get( "logDir" ); String logLevel = (String) params.get( "logLevel" ); Level level = null; if ( logLevel != null ) { logLevel = logLevel.trim( ); if ( "all".equalsIgnoreCase( logLevel ) ) { level = Level.ALL; } else if ( "config".equalsIgnoreCase( logLevel ) ) { level = Level.CONFIG; } else if ( "fine".equalsIgnoreCase( logLevel ) ) { level = Level.FINE; } else if ( "finer".equalsIgnoreCase( logLevel ) ) { level = Level.FINER; } else if ( "finest".equalsIgnoreCase( logLevel ) ) { level = Level.FINEST; } else if ( "info".equalsIgnoreCase( logLevel ) ) { level = Level.INFO; } else if ( "off".equalsIgnoreCase( logLevel ) ) { level = Level.OFF; } else if ( "severe".equalsIgnoreCase( logLevel ) ) { level = Level.SEVERE; } else if ( "warning".equalsIgnoreCase( logLevel ) ) { level = Level.WARNING; } } String logD = ( logDir == null ) ? config.getLogDirectory( ) : logDir; Level logL = ( level == null ) ? config.getLogLevel( ) : level; config.setLogConfig( logD, logL ); String logFile = (String) params.get( "logFile" ); if ( logFile != null ) config.setLogFile( logFile.trim( ) ); String scripts = (String) params.get( "scriptPath" ); HashMap map = new HashMap( ); map.put( EngineConstants.PROJECT_CLASSPATH_KEY, scripts ); config.setAppContext( map ); return config; }
Example 17
Source File: DatabaseMemory.java From BotLibre with Eclipse Public License 1.0 | 4 votes |
/** * Import the database into this instance. */ @SuppressWarnings("unchecked") public void importMemory(String database) { try { Map<String, String> properties = new HashMap<String, String>(); //properties.put(PersistenceUnitProperties.JDBC_DRIVER, DATABASE_DRIVER); properties.put(PersistenceUnitProperties.JDBC_URL, DATABASE_URL_PREFIX + database); //properties.put(PersistenceUnitProperties.JDBC_USER, DATABASE_USER); //properties.put(PersistenceUnitProperties.JDBC_PASSWORD, DATABASE_PASSWORD); Level debugLevel = this.bot.getDebugLevel(); String logLevel = "INFO"; if (debugLevel == Level.FINEST) { logLevel = "FINE"; } else if (debugLevel == Level.FINE) { logLevel = "INFO"; } else if (debugLevel == Level.SEVERE) { logLevel = "SEVER"; } else if (debugLevel == Level.WARNING) { logLevel = "WARNING"; } else if (debugLevel == Level.OFF) { logLevel = "OFF"; } properties.put(PersistenceUnitProperties.LOGGING_LEVEL, logLevel); EntityManagerFactory importFactory = Persistence.createEntityManagerFactory("import", properties); EntityManager importEntityManager = importFactory.createEntityManager(); Query query = importEntityManager.createQuery("Select v from Vertex v order by v.id"); int start = 0; query.setFirstResult(start); query.setMaxResults(100); List<Vertex> vertices = query.getResultList(); Map<Vertex, Vertex> identitySet = new IdentityHashMap<Vertex, Vertex>(vertices.size()); while (!vertices.isEmpty()) { for (Vertex vertex : vertices) { getShortTermMemory().importMerge(vertex, identitySet); } save(); start = start + 100; query.setFirstResult(start); query.setMaxResults(100); vertices = query.getResultList(); } importFactory.close(); } catch (RuntimeException failed) { this.bot.log(this, failed); throw failed; } }
Example 18
Source File: InternalSubLogger.java From SubServers-2 with Apache License 2.0 | 4 votes |
private void log(String line) { if (!line.startsWith(">")) { String msg = line; Level level; // REGEX Formatting String type = ""; Matcher matcher = Pattern.compile("^((?:\\s*\\[?([0-9]{2}:[0-9]{2}:[0-9]{2})]?)?[\\s\\/\\\\\\|]*(?:\\[|\\[.*\\/)?(MESSAGE|INFO|WARNING|WARN|ERROR|ERR|SEVERE)\\]?:?(?:\\s*>)?\\s*)").matcher(msg.replaceAll("\u001B\\[[;\\d]*m", "")); while (matcher.find()) { type = matcher.group(3).toUpperCase(); } msg = msg.replaceAll("^((?:\\s*\\[?([0-9]{2}:[0-9]{2}:[0-9]{2})]?)?[\\s\\/\\\\\\|]*(?:\\[|\\[.*\\/)?(MESSAGE|INFO|WARNING|WARN|ERROR|ERR|SEVERE)\\]?:?(?:\\s*>)?\\s*)", ""); // Determine LOG LEVEL switch (type) { case "WARNING": case "WARN": level = Level.WARNING; break; case "SEVERE": case "ERROR": case "ERR": level = Level.SEVERE; break; default: level = Level.INFO; } // Filter Message boolean allow = (SubAPI.getInstance().getInternals().sudo == getHandler() && SubAPI.getInstance().getInternals().canSudo) || (log.get() && (SubAPI.getInstance().getInternals().sudo == null || !SubAPI.getInstance().getInternals().canSudo)); List<SubLogFilter> filters = new ArrayList<SubLogFilter>(); filters.addAll(this.filters); for (SubLogFilter filter : filters) try { allow = (filter.log(level, msg) && allow); } catch (Throwable e) { new InvocationTargetException(e, "Exception while running SubLogger Event").printStackTrace(); } // Log to CONSOLE if (allow) Logger.get(name).log(level, msg); // Log to FILE if (writer != null) { writer.println(line); writer.flush(); } } }
Example 19
Source File: HttpException.java From nomulus with Apache License 2.0 | 4 votes |
public InternalServerErrorException(String message) { super(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message, null, Level.SEVERE); }
Example 20
Source File: NbCollectionsTest.java From netbeans with Apache License 2.0 | 4 votes |
protected Level logLevel() { return Level.SEVERE; }