Refine search
sbuf.append(event.timeStamp - LoggingEvent.getStartTime()); sbuf.append("</td>" + Layout.LINE_SEP); String escapedThread = Transform.escapeTags(event.getThreadName()); sbuf.append("<td title=\"" + escapedThread + " thread\">"); sbuf.append(escapedThread); if (event.getLevel().equals(Level.DEBUG)) { sbuf.append("<font color=\"#339933\">"); sbuf.append(Transform.escapeTags(String.valueOf(event.getLevel()))); LocationInfo locInfo = event.getLocationInformation(); sbuf.append("<td>"); sbuf.append(Transform.escapeTags(locInfo.getFileName())); sbuf.append(':'); sbuf.append(locInfo.getLineNumber()); sbuf.append("</td>" + Layout.LINE_SEP);
protected LogEvent toLogEvent(LoggingEvent element) { LogEvent answer = new LogEvent(); answer.setClassName(element.getFQNOfLoggerClass()); ThrowableInformation throwableInformation = element.getThrowableInformation(); if (throwableInformation != null) { ThrowableFormatter renderer = new ThrowableFormatter(); String[] stack = renderer.doRender(throwableInformation.getThrowable()); if (stack == null) { stack = element.getThrowableStrRep(); LocationInfo locationInformation = element.getLocationInformation(); if (locationInformation != null) { answer.setFileName(locationInformation.getFileName()); answer.setClassName(locationInformation.getClassName()); answer.setMethodName(locationInformation.getMethodName()); answer.setLineNumber(locationInformation.getLineNumber()); Level level = element.getLevel();
private org.apache.log4j.spi.LoggingEvent toLog4jEvent(LoggingEvent event, Level log4jLevel) { FormattingTuple ft = MessageFormatter.format(event.getMessage(), event.getArgumentArray(), event.getThrowable()); LocationInfo locationInfo = new LocationInfo(NA_SUBST, NA_SUBST, NA_SUBST, "0"); ThrowableInformation ti = null; Throwable t = ft.getThrowable(); if (t != null) ti = new ThrowableInformation(t); org.apache.log4j.spi.LoggingEvent log4jEvent = new org.apache.log4j.spi.LoggingEvent(FQCN, logger, event.getTimeStamp(), log4jLevel, ft.getMessage(), event.getThreadName(), ti, null, locationInfo, null); return log4jEvent; }
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; } } }
/** * 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); }
buf.append(Transform.escapeTags(event.getLoggerName())); buf.append("\" timestamp=\""); buf.append(event.timeStamp); buf.append("\" level=\""); buf.append(Transform.escapeTags(String.valueOf(event.getLevel()))); buf.append("\" thread=\""); buf.append(Transform.escapeTags(event.getThreadName())); buf.append("\">\r\n"); LocationInfo locationInfo = event.getLocationInformation(); buf.append("<log4j:locationInfo class=\""); buf.append(Transform.escapeTags(locationInfo.getClassName())); buf.append("\" method=\""); buf.append(Transform.escapeTags(locationInfo.getMethodName())); buf.append("\" file=\""); buf.append(Transform.escapeTags(locationInfo.getFileName())); buf.append("\" line=\""); buf.append(locationInfo.getLineNumber()); buf.append("\"/>\r\n");
@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); }
String getFullyQualifiedName(LoggingEvent event) { return event.getLocationInformation().getClassName(); } }
@Override protected void append(LoggingEvent event) { final LevelTag level = LevelTag.get(event.getLevel()); registry.counter(numMessages[level.ordinal()]).increment(); ThrowableInformation info = event.getThrowableInformation(); if (info != null) { LocationInfo loc = event.getLocationInformation(); final String file = (loc == null) ? "unknown" : loc.getFileName(); Id stackTraceId = numStackTraces[level.ordinal()] .withTag("exception", info.getThrowable().getClass().getSimpleName()) .withTag("file", file); registry.counter(stackTraceId).increment(); } }
/** * {@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()); } } }
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); } } }
public void log(Level level, String message) { LocationInfo locationInfo = new LocationInfo(new Throwable(), loggerName); MDC.put(LINE_NUMBER, locationInfo.getLineNumber()); MDC.put(FILE_NAME, locationInfo.getFileName()); MDC.put(CLASS_NAME, locationInfo.getClassName()); MDC.put(METHOD_NAME, locationInfo.getMethodName()); MDC.put(FQMETHOD_NAME, locationInfo.getClassName() + "." + locationInfo.getMethodName()); logger.log(level, message); MDC.remove(LINE_NUMBER); MDC.remove(FILE_NAME); MDC.remove(CLASS_NAME); MDC.remove(METHOD_NAME); MDC.remove(FQMETHOD_NAME); }
private void readObject(ObjectInputStream ois) throws java.io.IOException, ClassNotFoundException { ois.defaultReadObject(); readLevel(ois); // Make sure that no location info is available to Layouts if(locationInfo == null) locationInfo = new LocationInfo(null, null); }
/** Set the location information for this logging event. The collected information is cached for future use. */ public LocationInfo getLocationInformation() { if(locationInfo == null) { locationInfo = new LocationInfo(new Throwable(), fqnOfCategoryClass); } return locationInfo; }
public String getLineNumber() { return m_delegate.getLineNumber(); }
public String getMethodName() { return m_delegate.getMethodName(); } }
public String getFileName() { return m_delegate.getFileName(); }
public String getClassName() { return m_delegate.getClassName(); }