Package org.apache.log4j.spi

Examples of org.apache.log4j.spi.ThrowableInformation


        logstashEvent.put("@source_host", hostname);
        logstashEvent.put("@message", loggingEvent.getRenderedMessage());
        logstashEvent.put("@timestamp", dateFormat(timestamp));

        if (loggingEvent.getThrowableInformation() != null) {
            final ThrowableInformation throwableInformation = loggingEvent.getThrowableInformation();
            if (throwableInformation.getThrowable().getClass().getCanonicalName() != null) {
                exceptionInformation.put("exception_class", throwableInformation.getThrowable().getClass().getCanonicalName());
            }
            if (throwableInformation.getThrowable().getMessage() != null) {
                exceptionInformation.put("exception_message", throwableInformation.getThrowable().getMessage());
            }
            if (throwableInformation.getThrowableStrRep() != null) {
                String stackTrace = StringUtils.join(throwableInformation.getThrowableStrRep(), "\n");
                exceptionInformation.put("stacktrace", stackTrace);
            }
            addFieldData("exception", exceptionInformation);
        }
View Full Code Here


        if (logger.isLogging(level)) {
            // Then, generate the output message, including the required text
            // and optional throwable
            String message = null;
            Throwable throwable = null;
            final ThrowableInformation throwableInformation =
                    event.getThrowableInformation();

            if (throwableInformation != null) {
                throwable = throwableInformation.getThrowable();
            }

            if (layout != null) {
                message = layout.format(event);
            } else {
View Full Code Here

        } else {
            text = layout.format(event);
        }

        if (layout == null || layout.ignoresThrowable()) {
            ThrowableInformation info = event.getThrowableInformation();

            if (info != null) {
                thrown = info.getThrowable();
            }
        }

        // Translate the log level to an equivalent status code
        if (level.toInt() >= Level.ERROR_INT) {
View Full Code Here

      loggingEvent.setTimeStamp(timeStamp);
      loggingEvent.setLevel(level);
      loggingEvent.setThreadName(threadName);
      loggingEvent.setMessage(message);
      loggingEvent.setNDC(ndc);
      loggingEvent.setThrowableInformation(new ThrowableInformation(exception));
      loggingEvent.setLocationInformation(info);
      loggingEvent.setProperties(properties);
     
      events.add(loggingEvent);
View Full Code Here

      String[] strRep = new String[len];
      for (int i = 0; i < len; i++) {
        strRep[i] = (String) v.get(i);
      }
      // we've filled strRep, we now attach it to the event
      event.setThrowableInformation(new ThrowableInformation(strRep));
    } finally {
      if (statement != null) {
        statement.close();
      }
    }
View Full Code Here

    event.setLogger(logger);
    event.setTimeStamp(timeStamp);
    event.setLevel(levelImpl);
    event.setThreadName(threadName);
    event.setMessage(message);
    event.setThrowableInformation(new ThrowableInformation(exception));
    event.setLocationInformation(info);
    event.setNDC(ndc);
    event.setProperties(properties);
    return event;
  }
View Full Code Here

   * @see org.apache.log4j.pattern.PatternConverter#convert(org.apache.log4j.spi.LoggingEvent)
   */
  protected StringBuffer convert(LoggingEvent event) {
    StringBuffer buf = new StringBuffer(32);

    ThrowableInformation information = event.getThrowableInformation();

    if (information == null) {
      return buf;
    }

    String[] stringRep = information.getThrowableStrRep();

    int length = 0;

    if (getOption() == null) {
      length = stringRep.length;
View Full Code Here

      loggingEvent.setTimeStamp(timeStamp);
      loggingEvent.setLevel(levelImpl);
      loggingEvent.setThreadName(threadName);
      loggingEvent.setMessage(message);
      loggingEvent.setNDC(ndc);
      loggingEvent.setThrowableInformation(new ThrowableInformation(exception));
      loggingEvent.setLocationInformation(info);
      loggingEvent.setProperties(properties);
     
      events.add(loggingEvent);
    
View Full Code Here

    LocationInfo li =
      new LocationInfo(
        "myfile.java", "com.mycompany.util.MyClass", "myMethod", "321");

    ThrowableInformation tsr = new ThrowableInformation(new Exception());

    event = new LoggingEvent();
    event.setLogger(Logger.getLogger("com.mycompany.mylogger"));
    event.setTimeStamp(new Date().getTime());
    event.setLevel(org.apache.log4j.Level.DEBUG);
View Full Code Here

    root.debug("%throwable{100}, with exception", ex);

    //
    //  manufacture a pattern to get just the first two lines
    //
    String[] trace = new ThrowableInformation(ex).getThrowableStrRep();
    layout.setConversionPattern("%m%n%throwable{" + (2 - trace.length) + "}");
    layout.activateOptions();
    root.debug("%throwable{-n}, no exception");
    root.debug("%throwable{-n}, with exception", ex);
View Full Code Here

TOP

Related Classes of org.apache.log4j.spi.ThrowableInformation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.