Java Code Examples for org.apache.log4j.Level#equals()
The following examples show how to use
org.apache.log4j.Level#equals() .
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: EventCounter.java From hadoop with Apache License 2.0 | 6 votes |
@Override public void append(LoggingEvent event) { Level level = event.getLevel(); // depends on the api, == might not work // see HADOOP-7055 for details if (level.equals(Level.INFO)) { counts.incr(INFO); } else if (level.equals(Level.WARN)) { counts.incr(WARN); } else if (level.equals(Level.ERROR)) { counts.incr(ERROR); } else if (level.equals(Level.FATAL)) { counts.incr(FATAL); } }
Example 2
Source File: EventCounter.java From big-c with Apache License 2.0 | 6 votes |
@Override public void append(LoggingEvent event) { Level level = event.getLevel(); // depends on the api, == might not work // see HADOOP-7055 for details if (level.equals(Level.INFO)) { counts.incr(INFO); } else if (level.equals(Level.WARN)) { counts.incr(WARN); } else if (level.equals(Level.ERROR)) { counts.incr(ERROR); } else if (level.equals(Level.FATAL)) { counts.incr(FATAL); } }
Example 3
Source File: LogUtil.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
public static int findLevel(Level expectedLevel) { int count = 0; List<Log> logList = DubboAppender.logList; for (int i = 0; i < logList.size(); i++) { Level logLevel = logList.get(i).getLogLevel(); if (logLevel.equals(expectedLevel)) count++; } return count; }
Example 4
Source File: BaselineServiceImpl.java From cougar with Apache License 2.0 | 5 votes |
@Override public SimpleResponse logMessage(RequestContext ctx, String logString, String logLevel, TimeConstraints timeConstraints) throws SimpleException { ctx.setRequestLogExtension(new BaselineLogExtension(logString, null, null)); ctx.trace("Starting logMessage for {}", logString); // todo: should change this to an enum..?? at least change to a shorter list of possible values.. Level level = Level.toLevel(logLevel); if (level.equals(Level.ERROR)) { LOGGER.error(logString); } else if (level.equals(Level.WARN)) { LOGGER.warn(logString); } else if (level.equals(Level.INFO)) { LOGGER.info(logString); } else if (level.equals(Level.DEBUG)) { LOGGER.debug(logString); } else { throw new SimpleException(SimpleExceptionErrorCodeEnum.UNRECOGNIZED_VALUE, "Unsupported log level: "+logLevel); } SimpleResponse response = new SimpleResponse(); response.setMessage(logString + " logged at " + logLevel); return response; }
Example 5
Source File: PackageTranslator.java From olat with Apache License 2.0 | 5 votes |
/** */ @Override public String translate(String key, String[] args, Level missingTranslationLogLevel) { String val = translate(key, args, false); // if still null -> fallback to default locale (if not in debug mode) if (val == null) { if (Settings.isDebuging()) { val = getErrorMessage(key); } else { // try with fallBackToDefaultLocale val = translate(key, args, true); } } // else value got translated or there is at least an error message telling // which key was not found. // Note: val may be null if there is a localstrings file missing in the default language. use the online translation tool to double-check // Error: ! even in default language: missing translation key! if (val == null) { val = getErrorMessage(key); // TODO: 13.02.2009 Workaround to fix shibboleth-attribute WARN : 'no translation ... in org.olat.presentation.course.condition...' if (!packageName.startsWith("org.olat.presentation.course.condition")) { if (missingTranslationLogLevel != null && !missingTranslationLogLevel.equals(Level.OFF)) { if (missingTranslationLogLevel.equals(Level.ERROR)) { log.error(val, null); } else if (missingTranslationLogLevel.equals(Level.WARN)) { log.warn(val, null); } else if (missingTranslationLogLevel.equals(Level.INFO)) { log.info(val, null); } } } // don't use error message in GUI for production, use key instead (OLAT-5896) if (!Settings.isDebuging()) { val = key; } } return val; }
Example 6
Source File: PackageTranslator.java From olat with Apache License 2.0 | 5 votes |
/** */ @Override public String translate(String key, String[] args, Level missingTranslationLogLevel) { String val = translate(key, args, false); // if still null -> fallback to default locale (if not in debug mode) if (val == null) { if (Settings.isDebuging()) { val = getErrorMessage(key); } else { // try with fallBackToDefaultLocale val = translate(key, args, true); } } // else value got translated or there is at least an error message telling // which key was not found. // Note: val may be null if there is a localstrings file missing in the default language. use the online translation tool to double-check // Error: ! even in default language: missing translation key! if (val == null) { val = getErrorMessage(key); // TODO: 13.02.2009 Workaround to fix shibboleth-attribute WARN : 'no translation ... in org.olat.presentation.course.condition...' if (!packageName.startsWith("org.olat.presentation.course.condition")) { if (missingTranslationLogLevel != null && !missingTranslationLogLevel.equals(Level.OFF)) { if (missingTranslationLogLevel.equals(Level.ERROR)) { log.error(val, null); } else if (missingTranslationLogLevel.equals(Level.WARN)) { log.warn(val, null); } else if (missingTranslationLogLevel.equals(Level.INFO)) { log.info(val, null); } } } // don't use error message in GUI for production, use key instead (OLAT-5896) if (!Settings.isDebuging()) { val = key; } } return val; }
Example 7
Source File: LogUtil.java From dubbox with Apache License 2.0 | 5 votes |
public static int findMessage(Level expectedLevel, String expectedMessage) { int count = 0; List<Log> logList = DubboAppender.logList; for (int i = 0; i < logList.size(); i++) { Level logLevel = logList.get(i).getLogLevel(); if (logLevel.equals(expectedLevel)) { String logMessage = logList.get(i).getLogMessage(); if (logMessage.contains(expectedMessage)) count++; } } return count; }
Example 8
Source File: LogUtil.java From dubbox with Apache License 2.0 | 5 votes |
public static int findLevel(Level expectedLevel) { int count = 0; List<Log> logList = DubboAppender.logList; for (int i = 0; i < logList.size(); i++) { Level logLevel = logList.get(i).getLogLevel(); if (logLevel.equals(expectedLevel)) count++; } return count; }
Example 9
Source File: LogInitializer.java From zipkin-dependencies with Apache License 2.0 | 5 votes |
private static java.util.logging.Level toJul(Level log4Jlevel) { if (log4Jlevel.equals(Level.ALL)) return java.util.logging.Level.ALL; if (log4Jlevel.equals(Level.DEBUG)) return java.util.logging.Level.FINE; if (log4Jlevel.equals(Level.ERROR)) return java.util.logging.Level.SEVERE; if (log4Jlevel.equals(Level.FATAL)) return java.util.logging.Level.SEVERE; if (log4Jlevel.equals(Level.INFO)) return java.util.logging.Level.INFO; if (log4Jlevel.equals(Level.OFF)) return java.util.logging.Level.OFF; if (log4Jlevel.equals(Level.TRACE)) return java.util.logging.Level.FINEST; if (log4Jlevel.equals(Level.WARN)) return java.util.logging.Level.WARNING; throw new IllegalStateException("Unknown log level: " + log4Jlevel); }
Example 10
Source File: LogUtil.java From dubbox with Apache License 2.0 | 5 votes |
public static int findMessage(Level expectedLevel, String expectedMessage) { int count = 0; List<Log> logList = DubboAppender.logList; for (int i = 0; i < logList.size(); i++) { Level logLevel = logList.get(i).getLogLevel(); if (logLevel.equals(expectedLevel)) { String logMessage = logList.get(i).getLogMessage(); if (logMessage.contains(expectedMessage)) count++; } } return count; }
Example 11
Source File: LogUtil.java From dubbox with Apache License 2.0 | 5 votes |
public static int findLevel(Level expectedLevel) { int count = 0; List<Log> logList = DubboAppender.logList; for (int i = 0; i < logList.size(); i++) { Level logLevel = logList.get(i).getLogLevel(); if (logLevel.equals(expectedLevel)) count++; } return count; }
Example 12
Source File: LogUtil.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
public static int findMessage(Level expectedLevel, String expectedMessage) { int count = 0; List<Log> logList = DubboAppender.logList; for (int i = 0; i < logList.size(); i++) { Level logLevel = logList.get(i).getLogLevel(); if (logLevel.equals(expectedLevel)) { String logMessage = logList.get(i).getLogMessage(); if (logMessage.contains(expectedMessage)) count++; } } return count; }
Example 13
Source File: LogUtil.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
public static int findLevel(Level expectedLevel) { int count = 0; List<Log> logList = DubboAppender.logList; for (int i = 0; i < logList.size(); i++) { Level logLevel = logList.get(i).getLogLevel(); if (logLevel.equals(expectedLevel)) count++; } return count; }
Example 14
Source File: LogUtil.java From dubbox with Apache License 2.0 | 5 votes |
public static int findMessage(Level expectedLevel, String expectedMessage) { int count = 0; List<Log> logList = DubboAppender.logList; for (int i = 0; i < logList.size(); i++) { Level logLevel = logList.get(i).getLogLevel(); if (logLevel.equals(expectedLevel)) { String logMessage = logList.get(i).getLogMessage(); if (logMessage.contains(expectedMessage)) count++; } } return count; }
Example 15
Source File: LogUtil.java From dubbox with Apache License 2.0 | 5 votes |
public static int findLevel(Level expectedLevel) { int count = 0; List<Log> logList = DubboAppender.logList; for (int i = 0; i < logList.size(); i++) { Level logLevel = logList.get(i).getLogLevel(); if (logLevel.equals(expectedLevel)) count++; } return count; }
Example 16
Source File: LogInitializer.java From zipkin-sparkstreaming with Apache License 2.0 | 5 votes |
private static java.util.logging.Level toJul(Level log4Jlevel) { if (log4Jlevel.equals(Level.ALL)) return java.util.logging.Level.ALL; if (log4Jlevel.equals(Level.DEBUG)) return java.util.logging.Level.FINE; if (log4Jlevel.equals(Level.ERROR)) return java.util.logging.Level.SEVERE; if (log4Jlevel.equals(Level.FATAL)) return java.util.logging.Level.SEVERE; if (log4Jlevel.equals(Level.INFO)) return java.util.logging.Level.INFO; if (log4Jlevel.equals(Level.OFF)) return java.util.logging.Level.OFF; if (log4Jlevel.equals(Level.TRACE)) return java.util.logging.Level.FINEST; if (log4Jlevel.equals(Level.WARN)) return java.util.logging.Level.WARNING; throw new IllegalStateException("Unknown log level: " + log4Jlevel); }
Example 17
Source File: LogUtil.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
public static int findMessage(Level expectedLevel, String expectedMessage) { int count = 0; List<Log> logList = DubboAppender.logList; for (int i = 0; i < logList.size(); i++) { Level logLevel = logList.get(i).getLogLevel(); if (logLevel.equals(expectedLevel)) { String logMessage = logList.get(i).getLogMessage(); if (logMessage.contains(expectedMessage)) count++; } } return count; }
Example 18
Source File: PurgeUtilityHTMLLayout.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public String format( LoggingEvent event ) { Level logLevel = event.getLevel(); if ( sbuf.capacity() > MAX_CAPACITY ) { sbuf = new StringBuffer( BUF_SIZE ); } else { sbuf.setLength( 0 ); } if ( showTimeColumn() ) { DateFormat df = new SimpleDateFormat( "MM/dd/yyyy HH:mm:ss" ); Date date = new Date(); date.setTime( event.timeStamp ); String time = null; try { time = df.format( date ); } catch ( Exception ex ) { LogLog.error( "Error occured while converting date.", ex ); } sbuf.append( Layout.LINE_SEP + "<tr>" + Layout.LINE_SEP ); sbuf.append( "<td>" ); sbuf.append( Transform.escapeTags( time ) ); sbuf.append( "</td>" + Layout.LINE_SEP ); } sbuf.append( "<td title=\"Purge File/Folder\">" ); sbuf.append( Transform.escapeTags( MDC.get( PurgeUtilityLog.FILE_KEY ) ) ); sbuf.append( "</td>" + Layout.LINE_SEP ); if ( showLevelColumn() ) { sbuf.append( "<td title=\"Level\">" ); if ( logLevel.equals( Level.DEBUG ) ) { sbuf.append( "<font color=\"#339933\">" ); sbuf.append( Transform.escapeTags( String.valueOf( event.getLevel() ) ) ); sbuf.append( "</font>" ); } else if ( logLevel.isGreaterOrEqual( Level.WARN ) ) { sbuf.append( "<font color=\"#993300\"><strong>" ); sbuf.append( Transform.escapeTags( String.valueOf( event.getLevel() ) ) ); sbuf.append( "</strong></font>" ); } else { sbuf.append( Transform.escapeTags( String.valueOf( event.getLevel() ) ) ); } sbuf.append( "</td>" + Layout.LINE_SEP ); } if ( showCodeLineColumn() ) { LocationInfo locInfo = event.getLocationInformation(); sbuf.append( "<td>" ); sbuf.append( Transform.escapeTags( MDC.get( PurgeUtilityLogger.CODE_LINE ) ) ); // sbuf.append( Transform.escapeTags( locInfo.getFileName() ) ); // sbuf.append( ':' ); // sbuf.append( locInfo.getLineNumber() ); sbuf.append( "</td>" + Layout.LINE_SEP ); } sbuf.append( "<td title=\"Message\">" ); sbuf.append( Transform.escapeTags( event.getRenderedMessage() ) ); sbuf.append( "</td>" + Layout.LINE_SEP ); sbuf.append( "</tr>" + Layout.LINE_SEP ); if ( event.getNDC() != null ) { sbuf.append( "<tr><td bgcolor=\"#EEEEEE\" style=\"font-size : " + "xx-small;\" colspan=\"6\" title=\"Nested Diagnostic Context\">" ); sbuf.append( "NDC: " + Transform.escapeTags( event.getNDC() ) ); sbuf.append( "</td></tr>" + Layout.LINE_SEP ); } String[] s = event.getThrowableStrRep(); if ( s != null ) { sbuf.append( "<tr><td bgcolor=\"#993300\" style=\"color:White; font-size : xx-small;\" colspan=\"6\">" ); appendThrowableAsHTML( s, sbuf ); sbuf.append( "</td></tr>" + Layout.LINE_SEP ); } return sbuf.toString(); }
Example 19
Source File: LoggerUtil.java From Bats with Apache License 2.0 | 4 votes |
public static synchronized void changeLoggersLevel(@Nonnull Map<String, String> targetChanges) { /* remove existing patterns which are subsets of new patterns. for eg. if x.y.z.* will be removed if * there is x.y.* in the target changes. */ for (Map.Entry<String, String> changeEntry : targetChanges.entrySet()) { Iterator<Map.Entry<String, Pattern>> patternsIterator = patterns.entrySet().iterator(); while ((patternsIterator.hasNext())) { Map.Entry<String, Pattern> entry = patternsIterator.next(); String finer = entry.getKey(); String wider = changeEntry.getKey(); if (finer.length() < wider.length()) { continue; } boolean remove = false; for (int i = 0; i < wider.length(); i++) { if (wider.charAt(i) == '*') { remove = true; break; } if (wider.charAt(i) != finer.charAt(i)) { break; } else if (i == wider.length() - 1) { remove = true; } } if (remove) { patternsIterator.remove(); patternLevel.remove(finer); } } } for (Map.Entry<String, String> loggerEntry : targetChanges.entrySet()) { String target = loggerEntry.getKey(); patternLevel.put(target, Level.toLevel(loggerEntry.getValue())); patterns.put(target, Pattern.compile(target)); } if (!patternLevel.isEmpty()) { @SuppressWarnings("unchecked") Enumeration<Logger> loggerEnumeration = LogManager.getCurrentLoggers(); while (loggerEnumeration.hasMoreElements()) { Logger classLogger = loggerEnumeration.nextElement(); Level oldLevel = classLogger.getLevel(); Level newLevel = getLevelFor(classLogger.getName()); if (newLevel != null && (oldLevel == null || !newLevel.equals(oldLevel))) { logger.info("changing level of {} to {}", classLogger.getName(), newLevel); classLogger.setLevel(newLevel); } } } }
Example 20
Source File: SimpleControllerIntegrationTest.java From tutorials with MIT License | 4 votes |
private Condition<LoggingEvent> eventContains(String substring, Level level) { return new Condition<LoggingEvent>(entry -> (substring == null || (entry.getRenderedMessage() != null && entry.getRenderedMessage() .contains(substring))) && (level == null || level.equals(entry.getLevel())), String.format("entry with message '%s', level %s", substring, level)); }