Package org.apache.log4j.spi

Examples of org.apache.log4j.spi.ThrowableInformation


  /**
   * {@inheritDoc}
   */
  public void format(final LoggingEvent event, final StringBuffer toAppendTo) {
    ThrowableInformation information = event.getThrowableInformation();

    if (information != null) {
      String[] stringRep = information.getThrowableStrRep();

      int length = 0;

      if (option == null) {
        length = stringRep.length;
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

   * @return the writer
   * @throws IOException on problems generating the JSON
   */
  public Writer toJson(final Writer writer, final LoggingEvent event)
      throws IOException {
    ThrowableInformation ti = event.getThrowableInformation();
    toJson(writer,
           event.getLoggerName(),
           event.getTimeStamp(),
           event.getLevel().toString(),
           event.getThreadName(),
View Full Code Here

  }
 
  public int countExceptionsWithMessage(final String text) {
    int count = 0;
    for (LoggingEvent e: getLog()) {
      ThrowableInformation t = e.getThrowableInformation();
      if (t != null) {
        String m = t.getThrowable().getMessage();
        if (m.contains(text)) {
          count++;
        }
      }
    }
View Full Code Here

                         + expectedMessageExpression);
                }
            } // else they are both null

            // Check the exception ...
            ThrowableInformation throwableInfo = event.getThrowableInformation();
            if (expectedExceptionClass == null && throwableInfo != null) {
                fail("Log line " + lineNumber + " had unexpected exception: "
                     + event.getThrowableInformation().getThrowableStrRep());
            } else if (expectedExceptionClass != null && throwableInfo == null) {
                fail("Log line " + lineNumber + " was missing expected exception of type "
                     + expectedExceptionClass.getCanonicalName());
            } else if (expectedExceptionClass != null && throwableInfo != null) {
                Throwable actualException = throwableInfo.getThrowable();
                assertSame(expectedExceptionClass, actualException.getClass());
            } // else they are both null
        }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  public void format(final LoggingEvent event, final StringBuffer toAppendTo) {
    ThrowableInformation information = event.getThrowableInformation();

    if (information != null) {
      String[] stringRep = information.getThrowableStrRep();

      int length = 0;

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

        return new Object[0];
    }

    @Override
    public Throwable getThrowable() {
        ThrowableInformation ti = loggingEvent.getThrowableInformation();
        if (ti != null) {
            return ti.getThrowable();
        }

        return null;
    }
View Full Code Here

    ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
    PrintStream out = new PrintStream(byteOut);
    out.println(event.getMessage());
    out.println();

    ThrowableInformation throwableInfo = event.getThrowableInformation();
    if (throwableInfo != null) {
      Throwable thrown = throwableInfo.getThrowable();
      thrown.printStackTrace(out);
    }
    out.close();

    textArea.setText(new String(byteOut.toByteArray()));
View Full Code Here

                         + expectedMessageExpression);
                }
            } // else they are both null

            // Check the exception ...
            ThrowableInformation throwableInfo = event.getThrowableInformation();
            if (expectedExceptionClass == null && throwableInfo != null) {
                fail("Log line " + lineNumber + " had unexpected exception: "
                     + event.getThrowableInformation().getThrowableStrRep());
            } else if (expectedExceptionClass != null && throwableInfo == null) {
                fail("Log line " + lineNumber + " was missing expected exception of type "
                     + expectedExceptionClass.getCanonicalName());
            } else if (expectedExceptionClass != null && throwableInfo != null) {
                Throwable actualException = throwableInfo.getThrowable();
                assertSame(expectedExceptionClass, actualException.getClass());
            } // else they are both null
        }
View Full Code Here

      return Filter.NEUTRAL;
    }

    String msg = event.getRenderedMessage();

    ThrowableInformation throwableInfo = event.getThrowableInformation();
    String[] renderedThrowable = null;

    if(throwableInfo != null)
    {
      renderedThrowable = throwableInfo.getThrowableStrRep();
    }

    if((msg == null && renderedThrowable == null) || getStringToMatch() == null)
      return Filter.NEUTRAL;
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.