Package org.apache.log4j.spi

Examples of org.apache.log4j.spi.ThrowableInformation


    public void doAppend( LoggingEvent event )
    {
        m_output = true;
        m_priority = event.getLevel();
        m_message = (String)event.getMessage();
        final ThrowableInformation information = event.getThrowableInformation();
        if( null != information )
        {
            m_throwable = information.getThrowable();
        }
    }
View Full Code Here


  @Override
  protected void append(final LoggingEvent loggingEvent) {
    final StringBuilder buf = new StringBuilder();
    buf.append(getLayout().format(loggingEvent));
    final ThrowableInformation ti = loggingEvent.getThrowableInformation();

    if (ti != null) {
      final String[] cause = ti.getThrowableStrRep();

      for (final String line : cause) {
        buf.append(line).append('\n');
      }
    }
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

            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

      loggingEvent.setTimeStamp(timeStamp);
      loggingEvent.setLevel(levelImpl);
      loggingEvent.setThreadName(threadName);
      loggingEvent.setMessage(message);
      loggingEvent.setNDC(ndc);
      loggingEvent.setThrowableInformation(new ThrowableInformation(exception));
      loggingEvent.setProperties(properties);
     
      events.add(loggingEvent);
    
      logger = null;
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 (option == null) {
      length = stringRep.length;
View Full Code Here

                            message, null);
                    event.setLocationInformation(new LocationInfo(fileName,
                            className, methodName, lineNumber));
                    properties.putAll(mdc);
                    event.setTimeStamp(timeStamp);
                    event.setThrowableInformation(new ThrowableInformation(
                            exception));

                    event.setProperties(properties);
                    event.setThreadName(threadName);
                    event.setNDC(ndc);
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

         */
        logstashEvent.put("source_host", hostname);
        logstashEvent.put("message", loggingEvent.getRenderedMessage());

        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);
            }
            addEventData("exception", exceptionInformation);
        }

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.