/** * {@inheritDoc} */ public void format(final LoggingEvent event, final StringBuffer output) { LocationInfo locationInfo = event.getLocationInformation(); if (locationInfo != null) { output.append(locationInfo.fullInfo); } } }
/** * {@inheritDoc} */ public void format(final LoggingEvent event, final StringBuffer output) { LocationInfo locationInfo = event.getLocationInformation(); if (locationInfo != null) { output.append(locationInfo.getLineNumber()); } } }
/** * {@inheritDoc} */ public void format(final LoggingEvent event, final StringBuffer toAppendTo) { LocationInfo locationInfo = event.getLocationInformation(); if (locationInfo != null) { toAppendTo.append(locationInfo.getMethodName()); } } }
/** * {@inheritDoc} */ public void format(final LoggingEvent event, final StringBuffer output) { LocationInfo locationInfo = event.getLocationInformation(); if (locationInfo != null) { output.append(locationInfo.getFileName()); } } }
String getFullyQualifiedName(LoggingEvent event) { return event.getLocationInformation().getClassName(); } }
/** * Format a logging event. * @param event event to format. * @param toAppendTo string buffer to which class name will be appended. */ public void format(final LoggingEvent event, final StringBuffer toAppendTo) { final int initialLength = toAppendTo.length(); LocationInfo li = event.getLocationInformation(); if (li == null) { toAppendTo.append(LocationInfo.NA); } else { toAppendTo.append(li.getClassName()); } abbreviate(initialLength, toAppendTo); } }
/** * 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); }
public String convert(LoggingEvent event) { LocationInfo locationInfo = event.getLocationInformation(); switch(type) { case FULL_LOCATION_CONVERTER: return locationInfo.fullInfo; case METHOD_LOCATION_CONVERTER: return locationInfo.getMethodName(); case LINE_LOCATION_CONVERTER: return locationInfo.getLineNumber(); case FILE_LOCATION_CONVERTER: return locationInfo.getFileName(); default: return null; } } }
/** * {@inheritDoc} */ public LoggingEvent rewrite(final LoggingEvent source) { if (!properties.isEmpty()) { Map rewriteProps = new HashMap(source.getProperties()); for(Iterator iter = properties.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); if (!rewriteProps.containsKey(entry.getKey())) { rewriteProps.put(entry.getKey(), entry.getValue()); } } return new LoggingEvent( source.getFQNOfLoggerClass(), source.getLogger() != null ? source.getLogger(): Logger.getLogger(source.getLoggerName()), source.getTimeStamp(), source.getLevel(), source.getMessage(), source.getThreadName(), source.getThrowableInformation(), source.getNDC(), source.getLocationInformation(), rewriteProps); } return source; }
@Override public String format(LoggingEvent event) { java.util.logging.Level level = convertLevel(event.getLevel()); LogRecord logRecord = new LogRecord(level, event.getMessage().toString()); logRecord.setLoggerName(event.getLoggerName()); logRecord.setMillis(event.getTimeStamp()); logRecord.setSourceClassName(event.getLoggerName()); logRecord.setSourceMethodName(event.getLocationInformation().getMethodName()); logRecord.setThreadID((int) Thread.currentThread().getId()); return logger.format(logRecord); }
/** * 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); }
source.getThrowableInformation(), source.getNDC(), source.getLocationInformation(), props); } else {
/** * Info,error,warn,callback method implementation */ public void append(LoggingEvent event) { if (null == producer) { return; } if (locationInfo) { event.getLocationInformation(); } byte[] data = this.layout.format(event).getBytes(); try { Message msg = new Message(topic, tag, data); msg.getProperties().put(ProducerInstance.APPENDER_TYPE, ProducerInstance.LOG4J_APPENDER); //Send message and do not wait for the ack from the message broker. producer.sendOneway(msg); } catch (Exception e) { String msg = new String(data); errorHandler.error("Could not send message in RocketmqLog4jAppender [" + name + "].Message is :" + msg, e, ErrorCode.GENERIC_FAILURE); } }
/** * Adds the event to the buffer. When full the buffer is flushed. */ public void append(LoggingEvent event) { event.getNDC(); event.getThreadName(); // Get a copy of this thread's MDC. event.getMDCCopy(); if (locationInfo) { event.getLocationInformation(); } event.getRenderedMessage(); event.getThrowableStrRep(); buffer.add(event); if (buffer.size() >= bufferSize) flushBuffer(); }
protected void appendMavenCoordinates(LoggingEvent loggingEvent) { LocationInfo information = loggingEvent.getLocationInformation(); if (information != null) { String coordinates = MavenCoordHelper.getMavenCoordinates(information.getClassName()); if (coordinates != null) { loggingEvent.setProperty("maven.coordinates", coordinates); } } }
/** This method called by {@link AppenderSkeleton#doAppend} method to do most of the real appending work. */ public void append(LoggingEvent event) { if(!checkEntryConditions()) { return; } try { ObjectMessage msg = topicSession.createObjectMessage(); if(locationInfo) { event.getLocationInformation(); } msg.setObject(event); topicPublisher.publish(msg); } catch(JMSException e) { errorHandler.error("Could not publish message in JMSAppender ["+name+"].", e, ErrorCode.GENERIC_FAILURE); } catch(RuntimeException e) { errorHandler.error("Could not publish message in JMSAppender ["+name+"].", e, ErrorCode.GENERIC_FAILURE); } }
private static LoggingEvent replaceEventMessageWithoutThrowable(LoggingEvent event, String message) { return new LoggingEvent(event.getFQNOfLoggerClass(), event.getLogger(), event.getTimeStamp(), event.getLevel(), message, event.getThreadName(), null, event.getNDC(), event.getLocationInformation(), event.getProperties()); }
private static LoggingEvent replaceEventMessage(LoggingEvent event, String message) { return new LoggingEvent(event.getFQNOfLoggerClass(), event.getLogger(), event.getTimeStamp(), event.getLevel(), message, event.getThreadName(), event.getThrowableInformation(), event.getNDC(), event.getLocationInformation(), event.getProperties()); } }
/** Perform SMTPAppender specific appending actions, mainly adding the event to a cyclic buffer and checking if the event triggers an e-mail to be sent. */ public void append(LoggingEvent event) { if(!checkEntryConditions()) { return; } event.getThreadName(); event.getNDC(); event.getMDCCopy(); if(locationInfo) { event.getLocationInformation(); } event.getRenderedMessage(); event.getThrowableStrRep(); cb.add(event); if(evaluator.isTriggeringEvent(event)) { sendBuffer(); } }
String level = event.getLevel().toString(); long time = event.timeStamp; LocationInfo locationInfo = event.getLocationInformation();