/** Instantiate a LoggingEvent from the supplied parameters. <p>Except {@link #timeStamp} all the other fields of <code>LoggingEvent</code> are filled when actually needed. <p> @param logger The logger generating this event. @param level The level of this event. @param message The message of this event. @param throwable The throwable of this event. */ public LogEvent(String fqnOfCategoryClass, Category logger, Priority level, Object message, Throwable throwable) { this.fqnOfCategoryClass = fqnOfCategoryClass; this.logger = logger; this.categoryName = logger.getName(); this.level = level; this.message = message; if(throwable != null) { this.throwableInfo = new ThrowableInformation(throwable); } timeStamp = System.currentTimeMillis(); }
/** Instantiate a LoggingEvent from the supplied parameters. <p>Except {@link #timeStamp} all the other fields of <code>LoggingEvent</code> are filled when actually needed. <p> @param logger The logger generating this event. @param level The level of this event. @param message The message of this event. @param throwable The throwable of this event. */ public LoggingEvent(String fqnOfCategoryClass, Category logger, Priority level, Object message, Throwable throwable) { this.fqnOfCategoryClass = fqnOfCategoryClass; this.logger = logger; this.categoryName = logger.getName(); this.level = level; this.message = message; if(throwable != null) { this.throwableInfo = new ThrowableInformation(throwable, logger); } timeStamp = System.currentTimeMillis(); }
/** Instantiate a LoggingEvent from the supplied parameters. <p>Except {@link #timeStamp} all the other fields of <code>LoggingEvent</code> are filled when actually needed. <p> @param logger The logger generating this event. @param timeStamp the timestamp of this logging event @param level The level of this event. @param message The message of this event. @param throwable The throwable of this event. */ public LoggingEvent(String fqnOfCategoryClass, Category logger, long timeStamp, Priority level, Object message, Throwable throwable) { this.fqnOfCategoryClass = fqnOfCategoryClass; this.logger = logger; this.categoryName = logger.getName(); this.level = level; this.message = message; if(throwable != null) { this.throwableInfo = new ThrowableInformation(throwable, logger); } this.timeStamp = timeStamp; }
/** Instantiate a LoggingEvent from the supplied parameters. <p>Except {@link #timeStamp} all the other fields of <code>LoggingEvent</code> are filled when actually needed. <p> @param logger The logger generating this event. @param timeStamp the timestamp of this logging event @param level The level of this event. @param message The message of this event. @param throwable The throwable of this event. */ public LogEvent(String fqnOfCategoryClass, Category logger, long timeStamp, Priority level, Object message, Throwable throwable) { this.fqnOfCategoryClass = fqnOfCategoryClass; this.logger = logger; this.categoryName = logger.getName(); this.level = level; this.message = message; if(throwable != null) { this.throwableInfo = new ThrowableInformation(throwable); } this.timeStamp = timeStamp; }
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; }
/** Instantiate a LoggingEvent from the supplied parameters. <p>Except {@link #timeStamp} all the other fields of <code>LoggingEvent</code> are filled when actually needed. <p> @param logger The logger generating this event. @param level The level of this event. @param message The message of this event. @param throwable The throwable of this event. */ public LoggingEvent(String fqnOfCategoryClass, Category logger, Priority level, Object message, Throwable throwable) { this.fqnOfCategoryClass = fqnOfCategoryClass; this.logger = logger; this.categoryName = logger.getName(); this.level = level; this.message = message; if(throwable != null) { this.throwableInfo = new ThrowableInformation(throwable); } timeStamp = System.currentTimeMillis(); }
/** Instantiate a LoggingEvent from the supplied parameters. <p>Except {@link #timeStamp} all the other fields of <code>LoggingEvent</code> are filled when actually needed. <p> @param logger The logger generating this event. @param level The level of this event. @param message The message of this event. @param throwable The throwable of this event. */ public LogEvent(String fqnOfCategoryClass, Category logger, Priority level, Object message, Throwable throwable) { this.fqnOfCategoryClass = fqnOfCategoryClass; this.logger = logger; this.categoryName = logger.getName(); this.level = level; this.message = message; if(throwable != null) { this.throwableInfo = new ThrowableInformation(throwable); } timeStamp = System.currentTimeMillis(); }
/** Instantiate a LoggingEvent from the supplied parameters. <p>Except {@link #timeStamp} all the other fields of <code>LoggingEvent</code> are filled when actually needed. <p> @param logger The logger generating this event. @param level The level of this event. @param message The message of this event. @param throwable The throwable of this event. */ public LoggingEvent(String fqnOfCategoryClass, Category logger, Priority level, Object message, Throwable throwable) { this.fqnOfCategoryClass = fqnOfCategoryClass; this.logger = logger; this.categoryName = logger.getName(); this.level = level; this.message = message; if(throwable != null) { this.throwableInfo = new ThrowableInformation(throwable, logger); } timeStamp = System.currentTimeMillis(); }
/** Instantiate a LoggingEvent from the supplied parameters. <p>Except {@link #timeStamp} all the other fields of <code>LoggingEvent</code> are filled when actually needed. <p> @param logger The logger generating this event. @param timeStamp the timestamp of this logging event @param level The level of this event. @param message The message of this event. @param throwable The throwable of this event. */ public LoggingEvent(String fqnOfCategoryClass, Category logger, long timeStamp, Priority level, Object message, Throwable throwable) { this.fqnOfCategoryClass = fqnOfCategoryClass; this.logger = logger; this.categoryName = logger.getName(); this.level = level; this.message = message; if(throwable != null) { this.throwableInfo = new ThrowableInformation(throwable); } this.timeStamp = timeStamp; }
/** Instantiate a LoggingEvent from the supplied parameters. <p>Except {@link #timeStamp} all the other fields of <code>LoggingEvent</code> are filled when actually needed. <p> @param logger The logger generating this event. @param timeStamp the timestamp of this logging event @param level The level of this event. @param message The message of this event. @param throwable The throwable of this event. */ public LogEvent(String fqnOfCategoryClass, Category logger, long timeStamp, Priority level, Object message, Throwable throwable) { this.fqnOfCategoryClass = fqnOfCategoryClass; this.logger = logger; this.categoryName = logger.getName(); this.level = level; this.message = message; if(throwable != null) { this.throwableInfo = new ThrowableInformation(throwable); } this.timeStamp = timeStamp; }
/** Instantiate a LoggingEvent from the supplied parameters. <p>Except {@link #timeStamp} all the other fields of <code>LoggingEvent</code> are filled when actually needed. <p> @param logger The logger generating this event. @param timeStamp the timestamp of this logging event @param level The level of this event. @param message The message of this event. @param throwable The throwable of this event. */ public LoggingEvent(String fqnOfCategoryClass, Category logger, long timeStamp, Priority level, Object message, Throwable throwable) { this.fqnOfCategoryClass = fqnOfCategoryClass; this.logger = logger; this.categoryName = logger.getName(); this.level = level; this.message = message; if(throwable != null) { this.throwableInfo = new ThrowableInformation(throwable, logger); } this.timeStamp = timeStamp; }
private static final ThrowableInformation toThrownInformation( final Throwable thrown ) { ThrowableInformation info = null; if( thrown != null ) { info = new ThrowableInformation( thrown ); } return info; }
private static ThrowableInformation toThrownInformation( final Throwable thrown ) { ThrowableInformation info = null; if( thrown != null ) { info = new ThrowableInformation( thrown ); } return info; }
public ThrowableInformation getThrowableInformation() { final Throwable thrown = logRecord.getThrown(); if (cachedThrowableInformation == null && thrown != null) { cachedThrowableInformation = new ThrowableInformation(thrown, logger); } return cachedThrowableInformation; }
/** * Returns the stacktrace of the given exception as String.<p> * * @param e the exception * * @return the stacktrace as String */ private String formatStackTrace(Throwable e) { StringBuffer result = new StringBuffer(64); for (String s : new ThrowableInformation(e).getThrowableStrRep()) { result.append(s + "\n"); } return result.toString(); }
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; }
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; }
/** * Construct a new instance. * * @param rec the log record */ public ConvertedLoggingEvent(final ExtLogRecord rec) { super(rec.getLoggerClassName(), new DummyCategory(rec.getLoggerName()), rec.getMillis(), LevelMapping.getPriorityFor(rec.getLevel()), rec.getMessage(), rec.getThreadName(), rec.getThrown() == null ? null : new ThrowableInformation(rec.getThrown()), rec.getNdc(), new LocationInfo(new Throwable(), rec.getLoggerClassName()), Collections.singletonMap("org.jboss.logmanager.record", rec)); }
@Test public void testException() throws Throwable { Exception e = new NoRouteToHostException("that box caught fire 3 years ago"); ThrowableInformation ti = new ThrowableInformation(e); Log4Json l4j = new Log4Json(); long timeStamp = Time.now(); String outcome = l4j.toJson(new StringWriter(), "testException", timeStamp, "INFO", "quoted\"", "new line\n and {}", ti) .toString(); println("testException", outcome); }
@Test public void testException() throws Throwable { Exception e = new NoRouteToHostException("that box caught fire 3 years ago"); ThrowableInformation ti = new ThrowableInformation(e); Log4Json l4j = new Log4Json(); long timeStamp = Time.now(); String outcome = l4j.toJson(new StringWriter(), "testException", timeStamp, "INFO", "quoted\"", "new line\n and {}", ti) .toString(); println("testException", outcome); }