Examples of ThrowableInformation


Examples of org.apache.log4j.spi.ThrowableInformation

        /* 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

Examples of org.apache.log4j.spi.ThrowableInformation

                    fail("Log line " + lineNumber + " differed: \nwas     :\t" + actual + "\nexpected:\t" + 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

Examples of org.apache.log4j.spi.ThrowableInformation

    this.log = event.getLoggerName();
    this.time = event.getTimeStamp();
    this.level = event.getLevel().toString();
    this.msg = event.getMessage().toString();
    this.thread = event.getThreadName();
    final ThrowableInformation throwableInformation = event.getThrowableInformation();
        HashMap<String, Object> ex = new HashMap<String, Object>();
    if (throwableInformation != null) {
            if(throwableInformation.getThrowable().getClass().getCanonicalName() != null){
                ex.put("exception_class",throwableInformation.getThrowable().getClass().getCanonicalName());
            }
            if(throwableInformation.getThrowable().getMessage() != null) {
                ex.put("exception_message",throwableInformation.getThrowable().getMessage());
            }
            if( throwableInformation.getThrowableStrRep() != null) {
                String stackTrace = StringUtils.join(throwableInformation.getThrowableStrRep(),"\n");
                ex.put("stacktrace",stackTrace);
            }
    }
        this.exceptionInformation = ex;
    this.ndc = event.getNDC();
View Full Code Here

Examples of org.apache.log4j.spi.ThrowableInformation

    this.logger = logger;
    this.categoryName = logger.getName();
    this.level = level;
    this.message = message;
    if(throwable != null) {
      this.throwableInfo = new ThrowableInformation(throwable);
    }
    timeStamp = System.currentTimeMillis();
  }
View Full Code Here

Examples of org.apache.log4j.spi.ThrowableInformation

    this.logger = logger;
    this.categoryName = logger.getName();
    this.level = level;
    this.message = message;
    if(throwable != null) {
      this.throwableInfo = new ThrowableInformation(throwable);
    }

    this.timeStamp = timeStamp;
  }
View Full Code Here

Examples of org.apache.log4j.spi.ThrowableInformation

                    b.append(line).append(Layout.LINE_SEP);
                }
            }
        }
        else {
            ThrowableInformation throwableInformation = event.getThrowableInformation();
            if (throwableInformation != null) {
                Throwable throwable = throwableInformation.getThrowable();
                if (throwable != null) {
                    b.append(MESSAGE_PREFIX).append(throwable.getMessage()).append(Layout.LINE_SEP);
                    stackTraceFilterer.filter(throwable, true);
                    b.append(stackTracePrinter.prettyPrint(throwable));
                }
View Full Code Here

Examples of org.apache.log4j.spi.ThrowableInformation

  @Override
  public void close() {
  }

  private void logError(LoggingEvent event) {
    ThrowableInformation info = event.getThrowableInformation();

    if (info != null) {
      MessageProducer cat = Cat.getProducer();
      Throwable exception = info.getThrowable();
      Object message = event.getMessage();
      MessageTree tree = Cat.getManager().getThreadLocalMessageTree();

      if (tree == null) {
        Transaction t = cat.newTransaction("System", "Log4jException");
View Full Code Here

Examples of org.apache.log4j.spi.ThrowableInformation

    if (message instanceof Throwable) {
      data = buildExceptionStack((Throwable) message);
    } else {
      data = event.getMessage().toString();
    }
    ThrowableInformation info = event.getThrowableInformation();

    if (info != null) {
      data = data + '\n' + buildExceptionStack(info.getThrowable());
    }
    Cat.logTrace(type, name, Trace.SUCCESS, data);
  }
View Full Code Here

Examples of org.apache.log4j.spi.ThrowableInformation

  @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 = System.currentTimeMillis();
    String outcome = l4j.toJson(new StringWriter(),
        "testException",
        timeStamp,
View Full Code Here

Examples of org.apache.log4j.spi.ThrowableInformation

  @Test
  public void testNestedException() throws Throwable {
    Exception e =
        new NoRouteToHostException("that box caught fire 3 years ago");
    Exception ioe = new IOException("Datacenter problems", e);
    ThrowableInformation ti = new ThrowableInformation(ioe);
    Log4Json l4j = new Log4Json();
    long timeStamp = System.currentTimeMillis();
    String outcome = l4j.toJson(new StringWriter(),
        "testNestedException",
        timeStamp,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.