Java Code Examples for org.apache.log4j.Level#isGreaterOrEqual()
The following examples show how to use
org.apache.log4j.Level#isGreaterOrEqual() .
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: LambdaLogger.java From tinkerpop3 with GNU General Public License v2.0 | 6 votes |
/** * Conditionally log at the specified level. Does not call {@code supplier.get() } * unless {@code log.getLevel() >= level} (conditional message production). * * If the supplied object is a stream, conditionally log each object in * the stream on a separate line. */ protected void log(final Level level, final Supplier<Object> supplier) { if (log.getLoggerRepository().isDisabled(level.toInt())) { return; } if (level.isGreaterOrEqual(log.getEffectiveLevel())) { final Object o = Code.wrapThrow(() -> supplier.get()); if (o instanceof Stream) { final Stream<?> stream = (Stream<?>) o; try { stream.forEach(msg -> { log.callAppenders(new LambdaLoggingEvent(level, msg)); }); } finally { stream.close(); } } else { log.callAppenders(new LambdaLoggingEvent(level, o)); } } }
Example 2
Source File: LoggingReceiver.java From JVoiceXML with GNU Lesser General Public License v2.1 | 6 votes |
/** * Convenience method to send a log message to the debug pane. The event is * displayed, if a session exists and the configured logging level is equal * or greater to the level of the <code>logevent</code>. * * @param logevent * The received logging message. */ private void logMessage(final LoggingEvent logevent) { if (session == null) { return; } final String id = session.getSessionID(); final String threadName = logevent.getThreadName(); if (!id.equalsIgnoreCase(threadName)) { return; } final Level currentLevel = logevent.getLevel(); if (!currentLevel.isGreaterOrEqual(level)) { return; } final long timestamp = logevent.timeStamp; final Date date = new Date(timestamp); final String message = logevent.getMessage().toString(); browser.logMessage(date, message); }
Example 3
Source File: OptionConverter.java From logging-log4j2 with Apache License 2.0 | 6 votes |
public static org.apache.logging.log4j.Level convertLevel(Level level) { if (level == null) { return org.apache.logging.log4j.Level.ERROR; } if (level.isGreaterOrEqual(Level.FATAL)) { return org.apache.logging.log4j.Level.FATAL; } else if (level.isGreaterOrEqual(Level.ERROR)) { return org.apache.logging.log4j.Level.ERROR; } else if (level.isGreaterOrEqual(Level.WARN)) { return org.apache.logging.log4j.Level.WARN; } else if (level.isGreaterOrEqual(Level.INFO)) { return org.apache.logging.log4j.Level.INFO; } else if (level.isGreaterOrEqual(Level.DEBUG)) { return org.apache.logging.log4j.Level.DEBUG; } else if (level.isGreaterOrEqual(Level.TRACE)) { return org.apache.logging.log4j.Level.TRACE; } return org.apache.logging.log4j.Level.ALL; }
Example 4
Source File: XmlConfigurationFactory.java From logging-log4j2 with Apache License 2.0 | 6 votes |
private org.apache.logging.log4j.Level convertLevel(Level level) { if (level == null) { return org.apache.logging.log4j.Level.ERROR; } if (level.isGreaterOrEqual(Level.FATAL)) { return org.apache.logging.log4j.Level.FATAL; } else if (level.isGreaterOrEqual(Level.ERROR)) { return org.apache.logging.log4j.Level.ERROR; } else if (level.isGreaterOrEqual(Level.WARN)) { return org.apache.logging.log4j.Level.WARN; } else if (level.isGreaterOrEqual(Level.INFO)) { return org.apache.logging.log4j.Level.INFO; } else if (level.isGreaterOrEqual(Level.DEBUG)) { return org.apache.logging.log4j.Level.DEBUG; } else if (level.isGreaterOrEqual(Level.TRACE)) { return org.apache.logging.log4j.Level.TRACE; } return org.apache.logging.log4j.Level.ALL; }
Example 5
Source File: ThreadConfigurableLogger.java From datawave with Apache License 2.0 | 5 votes |
private boolean shouldLog(Level requestedLevel) { Level allowedLevel = ThreadLocalLogLevel.getLevel(log.getName()); if (allowedLevel == null || requestedLevel.isGreaterOrEqual(allowedLevel)) { return true; } else { return false; } }
Example 6
Source File: SafeLogUtils.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 4 votes |
private static boolean shouldTruncate(String message, Level loggerLevel, Level eventLevel) { return loggerLevel != null && loggerLevel.isGreaterOrEqual(Level.INFO) && eventLevel != null && !eventLevel.isGreaterOrEqual(Level.ERROR) && message.length() > OBFUSCATED_MESSAGE_LENGTH; }
Example 7
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(); }