Java Code Examples for java.util.logging.Level#CONFIG
The following examples show how to use
java.util.logging.Level#CONFIG .
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: SimpleTomEEFormatterTest.java From tomee with Apache License 2.0 | 7 votes |
@Test public void formatNotNullThrown() throws Exception { final String previousLineSeparatorProperty = System.getProperty(LINE_SEPARATOR_KEY); try { final String lineSeparatorValue = "\n"; final String logMessage = "An example log record"; final Level level = Level.CONFIG; final String exceptionMessage = "An example exception"; final Throwable thrown = new Exception(exceptionMessage); System.setProperty(LINE_SEPARATOR_KEY, lineSeparatorValue); final LogRecord logRecordInput = new LogRecord(level, logMessage); logRecordInput.setThrown(thrown); final Formatter formatter = new SimpleTomEEFormatter(); final String actualFormatOutput = formatter.format(logRecordInput); final String expectedFormatOutput = level.getLocalizedName() + " - " + logMessage + lineSeparatorValue + ExceptionUtils.getStackTrace(thrown); assertEquals(expectedFormatOutput, actualFormatOutput); } finally { System.setProperty(LINE_SEPARATOR_KEY, previousLineSeparatorProperty); } }
Example 2
Source File: LoggerF.java From openbd-core with GNU General Public License v3.0 | 6 votes |
private Level getLevel( String level ){ if ( level.equalsIgnoreCase("info") ) return Level.INFO; else if ( level.equalsIgnoreCase("all") ) return Level.ALL; else if ( level.equalsIgnoreCase("config") ) return Level.CONFIG; else if ( level.equalsIgnoreCase("fine") ) return Level.FINE; else if ( level.equalsIgnoreCase("finer") ) return Level.FINER; else if ( level.equalsIgnoreCase("off") ) return Level.OFF; else if ( level.equalsIgnoreCase("severe") ) return Level.SEVERE; else if ( level.equalsIgnoreCase("warning") ) return Level.WARNING; else return Level.INFO; }
Example 3
Source File: LevelEqualsRule.java From otroslogviewer with Apache License 2.0 | 6 votes |
/** * Deserialize the state of the object. * * @param in object input stream. * @throws IOException if error in reading stream for deserialization. */ private void readObject(final java.io.ObjectInputStream in) throws IOException { populateLevels(); int levelInt = in.readInt(); if (Level.INFO.intValue() == levelInt) { level = Level.INFO; } else if (Level.CONFIG.intValue() == levelInt) { level = Level.CONFIG; } else if (Level.FINE.intValue() == levelInt) { level = Level.FINE; } else if (Level.FINER.intValue() == levelInt) { level = Level.FINER; } else if (Level.FINEST.intValue() == levelInt) { level = Level.FINEST; } else if (Level.SEVERE.intValue() == levelInt) { level = Level.SEVERE; } else if (Level.WARNING.intValue() == levelInt) { level = Level.WARNING; } else { level = Level.FINEST; } }
Example 4
Source File: PAM.java From api-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 5
Source File: ForwardLogHandler.java From Thermos with GNU General Public License v3.0 | 6 votes |
@Override public void publish(LogRecord record) { Logger logger = getLogger(record.getLoggerName()); Throwable exception = record.getThrown(); Level level = record.getLevel(); String message = getFormatter().formatMessage(record); if (level == Level.SEVERE) { logger.error(message, exception); } else if (level == Level.WARNING) { logger.warn(message, exception); } else if (level == Level.INFO) { logger.info(message, exception); } else if (level == Level.CONFIG) { logger.debug(message, exception); } else { logger.trace(message, exception); } }
Example 6
Source File: KeymapModel.java From netbeans with Apache License 2.0 | 6 votes |
public void setCurrentProfile (String profileName) { String prev = getCurrentProfile(); if (!prev.equals(profileName)) { LogRecord rec = new LogRecord(Level.CONFIG, "KEYMAP_SET_PROFILE"); // NOI18N rec.setParameters(new Object[]{ profileName, prev }); rec.setResourceBundle(NbBundle.getBundle(KeymapModel.class)); rec.setResourceBundleName(KeymapModel.class.getPackage().getName() + ".Bundle"); rec.setLoggerName(UI_LOG.getName()); UI_LOG.log(rec); } final String profile = displayNameToName(profileName); waitFinished(new Runnable() { public void run() { for (KeymapManager m : getKeymapManagerInstances()) { m.setCurrentProfile(profile); } profileData = null; } }); }
Example 7
Source File: LogConfig.java From org.openntf.domino with Apache License 2.0 | 6 votes |
public static Level parseLevel(final String levelName) { if (Level.SEVERE.getName().equals(levelName)) { return Level.SEVERE; } if (Level.WARNING.getName().equals(levelName)) { return Level.WARNING; } if (Level.INFO.getName().equals(levelName)) { return Level.INFO; } if (Level.CONFIG.getName().equals(levelName)) { return Level.CONFIG; } if (Level.FINE.getName().equals(levelName)) { return Level.FINE; } if (Level.FINER.getName().equals(levelName)) { return Level.FINER; } if (Level.FINEST.getName().equals(levelName)) { return Level.FINEST; } System.err.println("LogConfig.parseLevel: Invalid name for log level: " + levelName); return null; }
Example 8
Source File: ChaincodeBase.java From fabric-chaincode-java with Apache License 2.0 | 6 votes |
private Level mapLevel(final String level) { if (level != null) { switch (level.toUpperCase().trim()) { case "CRITICAL": case "ERROR": return Level.SEVERE; case "WARNING": return Level.WARNING; case "INFO": return Level.INFO; case "NOTICE": return Level.CONFIG; case "DEBUG": return Level.FINEST; default: break; } } return Level.INFO; }
Example 9
Source File: XspOpenLogPhaseListener.java From org.openntf.domino with Apache License 2.0 | 5 votes |
/** * Converts an integer into a Java logging {@link Level} * * @param severity * int severity, 1 to 7 * @return Level corresponding to the relevant integer, defaulting to Level.CONFIG (4) */ private Level convertSeverity(final int severity) { Level internalLevel = null; switch (severity) { case 1: internalLevel = Level.SEVERE; break; case 2: internalLevel = Level.WARNING; break; case 3: internalLevel = Level.INFO; break; case 5: internalLevel = Level.FINE; break; case 6: internalLevel = Level.FINER; break; case 7: internalLevel = Level.FINEST; break; default: internalLevel = Level.CONFIG; } return internalLevel; }
Example 10
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 11
Source File: OldFileHandlerTest.java From j2objc with Apache License 2.0 | 5 votes |
protected void setUp() throws Exception { super.setUp(); manager.reset(); //initProp props.clear(); props.put("java.util.logging.FileHandler.level", "FINE"); props.put("java.util.logging.FileHandler.filter", className + "$MockFilter"); props.put("java.util.logging.FileHandler.formatter", className + "$MockFormatter"); props.put("java.util.logging.FileHandler.encoding", "iso-8859-1"); // limit to only two message props.put("java.util.logging.FileHandler.limit", "1000"); // rotation count is 2 props.put("java.util.logging.FileHandler.count", "2"); // using append mode props.put("java.util.logging.FileHandler.append", "true"); props.put("java.util.logging.FileHandler.pattern", "%t/log/java%u.test"); HOMEPATH = System.getProperty("user.home"); TEMPPATH = System.getProperty("java.io.tmpdir"); File file = new File(TEMPPATH + SEP + "log"); file.mkdir(); manager.readConfiguration(propertiesToInputStream(props)); handler = new FileHandler(); r = new LogRecord(Level.CONFIG, "msg"); }
Example 12
Source File: BuildInfo.java From netbeans with Apache License 2.0 | 5 votes |
static LogRecord logBuildInfoRec(){ LogRecord rec = new LogRecord(Level.CONFIG, BUILD_INFO_FILE); List<String> buildInfo = logBuildInfo(); if (buildInfo != null){ rec.setParameters(buildInfo.toArray()); } return rec; }
Example 13
Source File: TimeToFailure.java From netbeans with Apache License 2.0 | 5 votes |
static LogRecord logFailure() { LogRecord lr = new LogRecord(Level.CONFIG,TimeToFailure.class.getName() + ":" + totalTime); totalTime = 0; lastAction = 0; if(Installer.preferencesWritable) { prefs.putLong(MTTF,totalTime); } return lr; }
Example 14
Source File: LogViewMgr.java From netbeans with Apache License 2.0 | 5 votes |
private Map<String, String> getLevelMap() { Map<String, String> levelMap = new HashMap<String, String>(); for(Level l: new Level [] { Level.ALL, Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.INFO, Level.SEVERE, Level.WARNING } ) { String name = l.getName(); levelMap.put(name, l.getLocalizedName()); } return levelMap; }
Example 15
Source File: DefaultLogger.java From LiveEventBus with Apache License 2.0 | 5 votes |
@Override public void log(Level level, String msg, Throwable th) { if (level == Level.SEVERE) { Log.e(TAG, msg, th); } else if (level == Level.WARNING) { Log.w(TAG, msg, th); } else if (level == Level.INFO) { Log.i(TAG, msg, th); } else if (level == Level.CONFIG) { Log.d(TAG, msg, th); } else if (level != Level.OFF) { Log.v(TAG, msg, th); } }
Example 16
Source File: AuthorityFactories.java From sis with Apache License 2.0 | 5 votes |
/** * Logs the given exception at the given level. This method pretends that the logging come from * {@link CRS#getAuthorityFactory(String)}, which is the public facade for {@link #EPSG()}. */ private static void log(final Exception e, final boolean isWarning) { String message = e.getMessage(); // Prefer the locale of system administrator. if (message == null) { message = e.toString(); } final LogRecord record = new LogRecord(isWarning ? Level.WARNING : Level.CONFIG, message); if (isWarning && !(e instanceof UnavailableFactoryException)) { record.setThrown(e); } record.setLoggerName(Loggers.CRS_FACTORY); Logging.log(CRS.class, "getAuthorityFactory", record); }
Example 17
Source File: SlownessData.java From netbeans with Apache License 2.0 | 4 votes |
public LogRecord getLogRec(){ LogRecord rec = new LogRecord(Level.CONFIG, SLOWNESS_DATA); rec.setParameters(new Object[]{new Long(time), latestActionName, slownessType}); return rec; }
Example 18
Source File: DummyLogger.java From sis with Apache License 2.0 | 4 votes |
@Override public void config(String message) { level = Level.CONFIG; last = message; }
Example 19
Source File: ColoredConsoleLogger.java From moleculer-java with MIT License | 4 votes |
@Override public synchronized void log(LinkedList<LogRecord> records, StringBuilder lines) { Throwable cause; String msg; for (LogRecord record : records) { final Level l = record.getLevel(); if (l == Level.SEVERE) { coloredPrinter.print(SEVERE, Attribute.LIGHT, FColor.RED, BColor.NONE); } else if (l == Level.WARNING) { coloredPrinter.print(WARNING, Attribute.LIGHT, FColor.YELLOW, BColor.NONE); } else if (l == Level.INFO) { coloredPrinter.print(INFO, Attribute.LIGHT, FColor.GREEN, BColor.NONE); } else if (l == Level.CONFIG) { coloredPrinter.print(CONFIG, Attribute.CLEAR, FColor.CYAN, BColor.NONE); } else if (l == Level.FINE) { coloredPrinter.print(FINE, Attribute.CLEAR, FColor.MAGENTA, BColor.NONE); } else if (l == Level.FINER) { coloredPrinter.print(FINER, Attribute.CLEAR, FColor.BLUE, BColor.NONE); } else { coloredPrinter.print(FINEST, Attribute.CLEAR, FColor.RED, BColor.NONE); } msg = record.getMessage(); if (msg == null) { msg = "<null>"; } else { msg = msg.trim(); } coloredPrinter.println(msg, Attribute.LIGHT, FColor.WHITE, BColor.NONE); coloredPrinter.clear(); cause = record.getThrown(); if (cause != null) { cause.printStackTrace(errorWriter); } } }
Example 20
Source File: FastLogFormatter.java From moleculer-java with MIT License | 4 votes |
public String format(LogRecord record) { line.setLength(0); line.append('['); line.append(Instant.ofEpochMilli(record.getMillis()).toString()); final Level l = record.getLevel(); line.append("] "); if (l == Level.SEVERE) { line.append(SEVERE); } else if (l == Level.WARNING) { line.append(WARNING); } else if (l == Level.INFO) { line.append(INFO); } else if (l == Level.CONFIG) { line.append(CONFIG); } else if (l == Level.FINE) { line.append(FINE); } else if (l == Level.FINER) { line.append(FINER); } else { line.append(FINEST); } String className = record.getSourceClassName(); int n; if (className == null) { className = "unknown"; } else { n = className.lastIndexOf('$'); if (n > -1) { className = className.substring(0, n); } } line.append(className); n = line.length(); if (n > position || position - n > 30) { position = n; } n = 1 + position - n; if (n > 0) { for (int i = 0; i < n; i++) { line.append(' '); } } line.append(formatMessage(record)); line.append(BREAK); // Dump error final Throwable cause = record.getThrown(); if (cause != null) { StringBuilder errors = new StringBuilder(256); n = appendMessages(errors, cause); String trace = errors.toString().trim(); if (!trace.isEmpty()) { for (int i = 0; i < n; i++) { line.append('-'); } line.append(BREAK); line.append(trace); line.append(BREAK); for (int i = 0; i < n; i++) { line.append('-'); } line.append(BREAK); } line.append("Trace: "); line.append(cause.toString()); line.append(BREAK); StackTraceElement[] array = cause.getStackTrace(); if (array != null && array.length > 0) { for (n = 0; n < array.length; n++) { line.append("-> ["); line.append(n); line.append("] "); line.append(array[n]); line.append(BREAK); } } } return line.toString(); }