當前位置: 首頁>>代碼示例>>Java>>正文


Java LoggingEvent.getThrowableStrRep方法代碼示例

本文整理匯總了Java中org.apache.log4j.spi.LoggingEvent.getThrowableStrRep方法的典型用法代碼示例。如果您正苦於以下問題:Java LoggingEvent.getThrowableStrRep方法的具體用法?Java LoggingEvent.getThrowableStrRep怎麽用?Java LoggingEvent.getThrowableStrRep使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.log4j.spi.LoggingEvent的用法示例。


在下文中一共展示了LoggingEvent.getThrowableStrRep方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: append

import org.apache.log4j.spi.LoggingEvent; //導入方法依賴的package包/類
@Override
protected void append(final LoggingEvent event) {
    final StringBuilder buffer = new StringBuilder();
    buffer.append(layout.format(event));
    if(layout.ignoresThrowable()) {
        final String[] trace = event.getThrowableStrRep();
        if(trace != null) {
            buffer.append(Layout.LINE_SEP);
            for(final String t : trace) {
                buffer.append(t).append(Layout.LINE_SEP);
            }
        }
    }
    console.printf("\r%s%s%s", Ansi.ansi()
                    .saveCursorPosition()
                    .eraseLine(Ansi.Erase.ALL)
                    .fg(Ansi.Color.MAGENTA)
                    .restoreCursorPosition(),
            buffer.toString(), Ansi.ansi().reset());
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:21,代碼來源:TerminalLoggingAppender.java

示例2: append

import org.apache.log4j.spi.LoggingEvent; //導入方法依賴的package包/類
@Override
public void append(LoggingEvent event) {
    if (event == null) return;
    String line = this.layout.format(event);
    this.lines.add(line);
    if (event.getThrowableInformation() != null) {
        for (String t: event.getThrowableStrRep()) this.lines.add(t + "\n");
    }
    clean(this.maxlines);
}
 
開發者ID:yacy,項目名稱:yacy_grid_mcp,代碼行數:11,代碼來源:LogAppender.java

示例3: format

import org.apache.log4j.spi.LoggingEvent; //導入方法依賴的package包/類
@Override
public String format(LoggingEvent event)
{
    Map<String,Object> map = new TreeMap<String,Object>();
    map.put("timestamp",    new Date(event.getTimeStamp()));
    map.put("thread",       event.getThreadName());
    map.put("logger",       event.getLogger().getName());
    map.put("level",        event.getLevel().toString());
    map.put("message",      event.getRenderedMessage());

    if (event.getThrowableStrRep() != null) map.put("exception",    event.getThrowableStrRep());
    if (event.getNDC() != null)             map.put("ndc",          event.getNDC());
    if (tags != null)                       map.put("tags",         tags);

    if ((event.getProperties() != null) && ! event.getProperties().isEmpty())
    {
        map.put("mdc", event.getProperties());
    }


    if (processId != null)  map.put("processId", processId);
    if (hostname != null)   map.put("hostname", hostname);
    if (instanceId != null) map.put("instanceId", instanceId);

    if (enableLocation)
    {
        LocationInfo info = event.getLocationInformation();
        Map<String,Object> location = new TreeMap<String,Object>();
        location.put("className",  info.getClassName());
        location.put("methodName", info.getMethodName());
        location.put("fileName",   info.getFileName());
        location.put("lineNumber", info.getLineNumber());
        map.put("locationInfo", location);
    }

    return converterTL.get().convert(map);
}
 
開發者ID:kdgregory,項目名稱:log4j-aws-appenders,代碼行數:38,代碼來源:JsonLayout.java

示例4: LogMessage

import org.apache.log4j.spi.LoggingEvent; //導入方法依賴的package包/類
/**
 *  Constructs an instance from a Log4J event, using the specified layout.
 *
 *  @throws RuntimeException if any error occurred during formatting or conversion.
 *          Will include any root cause other than UnsupportedEncodingException.
 */
public LogMessage(LoggingEvent event, Layout layout)
{
    try
    {
        StringWriter out = new StringWriter(1024);
        out.write(layout.format(event));
        if ((event.getThrowableInformation() != null) && layout.ignoresThrowable())
        {
            for (String traceline : event.getThrowableStrRep())
            {
                out.write(traceline);
                out.write(Layout.LINE_SEP);
            }
        }
        out.close();

        this.timestamp = event.getTimeStamp();
        this.message = out.toString();
        this.messageBytes = this.message.getBytes("UTF-8");
    }
    catch (UnsupportedEncodingException e)
    {
        throw new RuntimeException("UnsupportedEncodingException when converting to UTF-8");
    }
    catch (Exception ex)
    {
        throw new RuntimeException("error creating LogMessage", ex);
    }
}
 
開發者ID:kdgregory,項目名稱:log4j-aws-appenders,代碼行數:36,代碼來源:LogMessage.java

示例5: format

import org.apache.log4j.spi.LoggingEvent; //導入方法依賴的package包/類
@Override
public String format(LoggingEvent event)
{
	StringBuilder sbuf = new StringBuilder();

	sbuf.append(Layout.LINE_SEP);
	sbuf.append("<tr><td>");
	sbuf.append(dateFormat.format(new Date(event.timeStamp)));
	sbuf.append("</td><td>");
	appendContextText(event, sbuf);
	sbuf.append("</td><td>");
	appendLevelText(event, sbuf);
	sbuf.append("</td><td>");
	appendLoggerName(event, sbuf);
	sbuf.append("</td>");
	sbuf.append(Layout.LINE_SEP);
	sbuf.append("<td>");
	sbuf.append(Transform.escapeTags(event.getRenderedMessage()));
	sbuf.append("</td></tr>");

	String s[] = event.getThrowableStrRep();
	if( s != null )
	{
		sbuf.append(Layout.LINE_SEP);
		sbuf.append("<tr><td bgcolor=\"#993300\" style=\"color:White; font-size : xx-small;\" colspan=\"5\">");
		appendThrowableAsHTML(s, sbuf);
		sbuf.append("</td></tr>");
	}

	return sbuf.toString();
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:32,代碼來源:HTMLLayout3.java

示例6: format

import org.apache.log4j.spi.LoggingEvent; //導入方法依賴的package包/類
@Override
public String format(LoggingEvent event)
{
	StringBuilder sbuf = new StringBuilder(60);

	sbuf.append(DATE_FORMATTER.format(new Date(event.timeStamp)));
	sbuf.append(',');

	sbuf.append(event.getLevel());
	sbuf.append(',');

	appendLoggerName(event, sbuf);
	sbuf.append(',');

	// The following appends it's own ending comma.
	appendContextText(event, sbuf);

	sbuf.append(escapeForCsv(event.getRenderedMessage()));
	sbuf.append(',');

	String s[] = event.getThrowableStrRep();
	if( s != null )
	{
		appendThrowableAsHTML(s, sbuf);
	}

	sbuf.append(Layout.LINE_SEP);

	return sbuf.toString();
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:31,代碼來源:CsvLayout1.java

示例7: append

import org.apache.log4j.spi.LoggingEvent; //導入方法依賴的package包/類
@Override
protected void append(final LoggingEvent event) {
    final StringBuilder buffer = new StringBuilder();
    buffer.append(layout.format(event));
    if(layout.ignoresThrowable()) {
        final String[] trace = event.getThrowableStrRep();
        if(trace != null) {
            buffer.append(Layout.LINE_SEP);
            for(final String t : trace) {
                buffer.append(t).append(Layout.LINE_SEP);
            }
        }
    }
    FoundationKitFunctionsLibrary.NSLog("%@", buffer.toString());
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:16,代碼來源:SystemLogAppender.java

示例8: append

import org.apache.log4j.spi.LoggingEvent; //導入方法依賴的package包/類
public
void append(LoggingEvent event) {

  if(!isAsSevereAsThreshold(event.getLevel()))
    return;

  // We must not attempt to append if sqw is null.
  if(sqw == null) {
    errorHandler.error("No syslog host is set for SyslogAppedender named \""+
          this.name+"\".");
    return;
  }

  if (!layoutHeaderChecked) {
      if (layout != null && layout.getHeader() != null) {
          sendLayoutMessage(layout.getHeader());
      }
      layoutHeaderChecked = true;
  }

  String hdr = getPacketHeader(event.timeStamp);
  String packet = layout.format(event);
  if(facilityPrinting || hdr.length() > 0) {
      StringBuffer buf = new StringBuffer(hdr);
      if(facilityPrinting) {
          buf.append(facilityStr);
      }
      buf.append(packet);
      packet = buf.toString();
  }

  sqw.setLevel(event.getLevel().getSyslogEquivalent());
  //
  //   if message has a remote likelihood of exceeding 1024 bytes
  //      when encoded, consider splitting message into multiple packets
  if (packet.length() > 256) {
      splitPacket(hdr, packet);
  } else {
      sqw.write(packet);
  }

  if (layout.ignoresThrowable()) {
    String[] s = event.getThrowableStrRep();
    if (s != null) {
      for(int i = 0; i < s.length; i++) {
          if (s[i].startsWith("\t")) {
             sqw.write(hdr+TAB+s[i].substring(1));
          } else {
             sqw.write(hdr+s[i]);
          }
      }
    }
  }
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:55,代碼來源:SyslogAppender.java

示例9: format

import org.apache.log4j.spi.LoggingEvent; //導入方法依賴的package包/類
@Override
public String format(LoggingEvent event)
{
	if( sbuf.capacity() > 1024 )
	{
		sbuf = new StringBuilder(256);
	}
	else
	{
		sbuf.setLength(0);
	}
	sbuf.append(Layout.LINE_SEP);
	sbuf.append("<tr>");
	sbuf.append(Layout.LINE_SEP);
	sbuf.append("<td>");
	sbuf.append(dateFormat.format(new Date(event.timeStamp)));
	sbuf.append("</td>");
	sbuf.append(Layout.LINE_SEP);
	sbuf.append("<td>");
	if( event.getLevel().equals(Level.DEBUG) )
	{
		sbuf.append("<font color=\"#339933\">");
		sbuf.append(event.getLevel());
		sbuf.append("</font>");
	}
	else if( event.getLevel().isGreaterOrEqual(Level.WARN) )
	{
		sbuf.append("<font color=\"#993300\"><strong>");
		sbuf.append(event.getLevel());
		sbuf.append("</strong></font>");
	}
	else
	{
		sbuf.append(event.getLevel());
	}
	sbuf.append("</td>");
	sbuf.append(Layout.LINE_SEP);
	sbuf.append("<td>");
	sbuf.append(Transform.escapeTags(event.getLoggerName()));
	sbuf.append("</td>");
	sbuf.append(Layout.LINE_SEP);
	if( locationInfo )
	{
		LocationInfo locInfo = event.getLocationInformation();
		sbuf.append("<td>");
		sbuf.append(Transform.escapeTags(locInfo.getFileName()));
		sbuf.append(':');
		sbuf.append(locInfo.getLineNumber());
		sbuf.append("</td>");
		sbuf.append(Layout.LINE_SEP);
	}
	sbuf.append("<td>");
	sbuf.append(Transform.escapeTags(event.getRenderedMessage()));
	sbuf.append("</td>");
	sbuf.append(Layout.LINE_SEP);
	sbuf.append("</tr>");
	sbuf.append(Layout.LINE_SEP);
	if( event.getNDC() != null )
	{
		sbuf.append("<tr><td bgcolor=\"#EEEEEE\" style=\"font-size : xx-small;\" colspan=\"6\" title=\"Nested Diagnostic Context\">");
		sbuf.append("NDC: ");
		sbuf.append(Transform.escapeTags(event.getNDC()));
		sbuf.append("</td></tr>");
		sbuf.append(Layout.LINE_SEP);
	}
	String s[] = event.getThrowableStrRep();
	if( s != null )
	{
		sbuf.append("<tr><td bgcolor=\"#993300\" style=\"color:White; font-size : xx-small;\" colspan=\"6\">");
		appendThrowableAsHTML(s, sbuf);
		sbuf.append("</td></tr>");
		sbuf.append(Layout.LINE_SEP);
	}
	return sbuf.toString();
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:76,代碼來源:HTMLLayout2.java


注:本文中的org.apache.log4j.spi.LoggingEvent.getThrowableStrRep方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。