Package org.apache.log4j.spi

Examples of org.apache.log4j.spi.ThrowableInformation


    public boolean requiresLayout() {
        return true;
    }

    public static Throwable getThrowable(LoggingEvent event) {
        ThrowableInformation information = event.getThrowableInformation();
        if (information != null) {
            return information.getThrowable();
        } else {
            return null;
        }
    }
View Full Code Here


        return StringUtility.emptyStringIfNull(log.getThreadName());
    }

    @Override
    public String getThrowableInfo() {
        ThrowableInformation throwable = log.getThrowableInformation();
        String throwableInfo = "";

        if (throwable != null) {
            throwableInfo = throwable.getThrowable().getMessage();
        }
        return throwableInfo;
    }
View Full Code Here

        Assert.assertEquals("DEBUG", socketLogEvent.getLevel());

        when(mockLog.getThreadName()).thenReturn("ThreadName");
        Assert.assertEquals("ThreadName", socketLogEvent.getThreadName());

        when(mockLog.getThrowableInformation()).thenReturn(new ThrowableInformation(new Throwable("Exception")));
        Assert.assertEquals("Exception", socketLogEvent.getThrowableInfo());
    }
View Full Code Here

        return loggingEvent.getThreadName();
    }

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

        return null;
    }
View Full Code Here

            String renderedMessage = event.getRenderedMessage();
            if (renderedMessage != null)
            {
                message.append(renderedMessage);
            }
            ThrowableInformation ti = event.getThrowableInformation();
            if (ti != null)
            {
                Throwable t = ti.getThrowable();
                if (t != null)
                {
                    if (message.length() > 0)
                    {
                        message.append(":");
View Full Code Here

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

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

        int length = stringRep.length;
        if (maxLines < 0) {
            length += maxLines;
        } else if (length > maxLines) {
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

  }
 
  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

        String text = layout.format(event);
        Throwable thrown = null;

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

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

        Level level = event.getLevel();
        int severity = IStatus.OK;
View Full Code Here

        /* java.util.Map properties */ null );
    logger.callAppenders( event );
  }

  private static final ThrowableInformation toThrownInformation( final Throwable thrown ) {
    ThrowableInformation info = null;
    if( thrown != null ) {
      info = new ThrowableInformation( thrown );
    }
    return info;
  }
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.