Java Code Examples for org.apache.log4j.spi.LoggingEvent#getLevel()
The following examples show how to use
org.apache.log4j.spi.LoggingEvent#getLevel() .
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 RDFS with Apache License 2.0 | 6 votes |
public void append(LoggingEvent event) { Level level = event.getLevel(); if (level == Level.INFO) { counts.incr(INFO); } else if (level == Level.WARN) { counts.incr(WARN); } else if (level == Level.ERROR) { counts.incr(ERROR); } else if (level == Level.FATAL) { counts.incr(FATAL); } }
Example 2
Source File: AlertsSyslogAppender.java From cloudstack with Apache License 2.0 | 6 votes |
@Override protected void append(LoggingEvent event) { if (!isAsSevereAsThreshold(event.getLevel())) { return; } if (_syslogAppenders != null && !_syslogAppenders.isEmpty()) { try { String logMessage = event.getRenderedMessage(); if (logMessage.contains("alertType") && logMessage.contains("message")) { parseMessage(logMessage); String syslogMessage = createSyslogMessage(); LoggingEvent syslogEvent = new LoggingEvent(event.getFQNOfLoggerClass(), event.getLogger(), event.getLevel(), syslogMessage, null); for (SyslogAppender syslogAppender : _syslogAppenders) { syslogAppender.append(syslogEvent); } } } catch (Exception e) { errorHandler.error(e.getMessage()); } } }
Example 3
Source File: MockAppenderLog4J.java From openpojo with Apache License 2.0 | 6 votes |
private Priority extractPriority(final LoggingEvent event) { if (event.getLevel().equals(Level.TRACE)) { return Priority.TRACE; } if (event.getLevel().equals(Level.DEBUG)) { return Priority.DEBUG; } if (event.getLevel().equals(Level.INFO)) { return Priority.INFO; } if (event.getLevel().equals(Level.WARN)) { return Priority.WARN; } if (event.getLevel().equals(Level.ERROR)) { return Priority.ERROR; } if (event.getLevel().equals(Level.FATAL)) { return Priority.FATAL; } throw new IllegalArgumentException("Unknown Logged Level" + event.getLevel()); }
Example 4
Source File: EventCounter.java From hadoop-gpu with Apache License 2.0 | 6 votes |
public void append(LoggingEvent event) { Level level = event.getLevel(); if (level == Level.INFO) { counts.incr(INFO); } else if (level == Level.WARN) { counts.incr(WARN); } else if (level == Level.ERROR) { counts.incr(ERROR); } else if (level == Level.FATAL) { counts.incr(FATAL); } }
Example 5
Source File: AsyncAppenderTestCase.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
/** * {@inheritDoc} */ public void append(final LoggingEvent event) { synchronized (monitor) { dispatcher = Thread.currentThread(); super.append(event); // // if fatal, echo messages for testLoggingInDispatcher // if (event.getLevel() == Level.FATAL) { Logger logger = Logger.getLogger(event.getLoggerName()); logger.error(event.getMessage().toString()); logger.warn(event.getMessage().toString()); logger.info(event.getMessage().toString()); logger.debug(event.getMessage().toString()); } } }
Example 6
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 7
Source File: JulAppender.java From presto with Apache License 2.0 | 6 votes |
/** * Append a log event at the appropriate JUL level, depending on the log4j level. */ @Override protected void append(LoggingEvent loggingEvent) { java.util.logging.Logger logger = java.util.logging.Logger.getLogger(loggingEvent.getLoggerName()); if (logger == null) { LogLog.warn(format("Cannot obtain JUL %s. Verify that this appender is used while an appropriate LogManager is active.", loggingEvent.getLoggerName())); return; } Level level = loggingEvent.getLevel(); java.util.logging.Level julLevel = convertLog4jLevel(level); LogRecord record = new LogRecord(julLevel, loggingEvent.getRenderedMessage()); record.setMillis(loggingEvent.getTimeStamp()); LocationInfo location = loggingEvent.getLocationInformation(); if (location != null) { record.setSourceClassName(location.getClassName()); record.setSourceMethodName(location.getMethodName()); } logger.log(record); }
Example 8
Source File: LoggingTester.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected void append(final LoggingEvent event) { String _renderedMessage = event.getRenderedMessage(); String _loggerName = event.getLoggerName(); long _timeStamp = event.getTimeStamp(); Level _level = event.getLevel(); final LoggingTester.LogEntry entry = new LoggingTester.LogEntry(_renderedMessage, _loggerName, _timeStamp, _level); this.events.add(entry); }
Example 9
Source File: InfoOnlyLogLayout.java From systemsgenetics with GNU General Public License v3.0 | 5 votes |
@Override public String format(LoggingEvent event) { if (event.getLevel() == Level.INFO) { sbuf.setLength(0); sbuf.append(event.getRenderedMessage()); sbuf.append(LINE_SEP); return sbuf.toString(); } else { return ""; } }
Example 10
Source File: LoggerUtilTest.java From attic-apex-core with Apache License 2.0 | 5 votes |
@Override public void append(LoggingEvent event) { mdcProperties = event.getProperties(); lastMessage = event.getRenderedMessage(); level = event.getLevel(); }
Example 11
Source File: EventDetails.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Creates a new <code>EventDetails</code> instance. * * @param aEvent a <code>LoggingEvent</code> value */ EventDetails(LoggingEvent aEvent) { this(aEvent.timeStamp, aEvent.getLevel(), aEvent.getLoggerName(), aEvent.getNDC(), aEvent.getThreadName(), aEvent.getRenderedMessage(), aEvent.getThrowableStrRep(), (aEvent.getLocationInformation() == null) ? null : aEvent.getLocationInformation().fullInfo); }
Example 12
Source File: LoggingTester.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected void append(final LoggingEvent event) { String _renderedMessage = event.getRenderedMessage(); String _loggerName = event.getLoggerName(); long _timeStamp = event.getTimeStamp(); Level _level = event.getLevel(); final LoggingTester.LogEntry entry = new LoggingTester.LogEntry(_renderedMessage, _loggerName, _timeStamp, _level); this.events.add(entry); }
Example 13
Source File: TajoLogEventCounter.java From tajo with Apache License 2.0 | 5 votes |
@Override public void append(LoggingEvent event) { Level level = event.getLevel(); String levelStr = level.toString(); if (level == Level.INFO || "INFO".equalsIgnoreCase(levelStr)) { counts.incr(INFO); } else if (level == Level.WARN || "WARN".equalsIgnoreCase(levelStr)) { counts.incr(WARN); } else if (level == Level.ERROR || "ERROR".equalsIgnoreCase(levelStr)) { counts.incr(ERROR); } else if (level == Level.FATAL || "FATAL".equalsIgnoreCase(levelStr)) { counts.incr(FATAL); } }
Example 14
Source File: Appender.java From 07kit with GNU General Public License v3.0 | 5 votes |
@Override public void append(LoggingEvent event) { if (event.getLevel() == Level.DEBUG) { return; } super.append(event); }
Example 15
Source File: GraphingStatisticsAppender.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
protected void append(LoggingEvent event) { Object logMessage = event.getMessage(); if (logMessage instanceof GroupedTimingStatistics && this.chartGenerator != null) { this.chartGenerator.appendData((GroupedTimingStatistics)logMessage); this.hasUnflushedData = true; this.lastAppendedEventLevel = event.getLevel(); if (this.numLoggedStatistics.incrementAndGet() % (long)this.getDataPointsPerGraph() == 0L) { this.flush(); } } }
Example 16
Source File: TajoLogEventCounter.java From incubator-tajo with Apache License 2.0 | 5 votes |
@Override public void append(LoggingEvent event) { Level level = event.getLevel(); String levelStr = level.toString(); if (level == Level.INFO || "INFO".equalsIgnoreCase(levelStr)) { counts.incr(INFO); } else if (level == Level.WARN || "WARN".equalsIgnoreCase(levelStr)) { counts.incr(WARN); } else if (level == Level.ERROR || "ERROR".equalsIgnoreCase(levelStr)) { counts.incr(ERROR); } else if (level == Level.FATAL || "FATAL".equalsIgnoreCase(levelStr)) { counts.incr(FATAL); } }
Example 17
Source File: DBase.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
@Override public int decide (LoggingEvent e) { Level l = e.getLevel (); if ((l == Level.WARN) || (l == Level.ERROR) || (l == Level.FATAL)) { return Filter.ACCEPT; } return Filter.NEUTRAL; }
Example 18
Source File: Log.java From openemm with GNU Affero General Public License v3.0 | 5 votes |
@Override public int decide (LoggingEvent e) { Level l = e.getLevel (); if ((l == Level.DEBUG) || (l == Level.INFO) || (l == Level.WARN) || (l == Level.ERROR) || (l == Level.FATAL)) { return Filter.ACCEPT; } return Filter.NEUTRAL; }
Example 19
Source File: LoggingPattern.java From pubsub with Apache License 2.0 | 4 votes |
@Override public String format(LoggingEvent event) { return event.getLevel() + "-" + event.getMessage() + Layout.LINE_SEP; }
Example 20
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(); }