• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ThrowableProxy类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.logging.log4j.core.impl.ThrowableProxy的典型用法代码示例。如果您正苦于以下问题:Java ThrowableProxy类的具体用法?Java ThrowableProxy怎么用?Java ThrowableProxy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ThrowableProxy类属于org.apache.logging.log4j.core.impl包,在下文中一共展示了ThrowableProxy类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: format

import org.apache.logging.log4j.core.impl.ThrowableProxy; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void format(final LogEvent event, final StringBuilder toAppendTo) {
    final ThrowableProxy proxy = event.getThrownProxy();
    final Throwable throwable = event.getThrown();
    if ((throwable != null || proxy != null) && options.anyLines()) {
        if (proxy == null) {
            super.format(event, toAppendTo);
            return;
        }
        final String extStackTrace = proxy.getExtendedStackTraceAsString(options.getIgnorePackages(),
                options.getTextRenderer(), getSuffix(event), options.getSeparator());
        final int len = toAppendTo.length();
        if (len > 0 && !Character.isWhitespace(toAppendTo.charAt(len - 1))) {
            toAppendTo.append(' ');
        }
        toAppendTo.append(extStackTrace);
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:22,代码来源:ExtendedThrowablePatternConverter.java


示例2: testDeserializedLogEventWithThrowableProxyButNoThrowable

import org.apache.logging.log4j.core.impl.ThrowableProxy; //导入依赖的package包/类
@Test
public void testDeserializedLogEventWithThrowableProxyButNoThrowable() {
	final ExtendedThrowablePatternConverter converter = ExtendedThrowablePatternConverter.newInstance(null, null);
	final Throwable originalThrowable = new Exception("something bad happened");
	final ThrowableProxy throwableProxy = new ThrowableProxy(originalThrowable);
	final Throwable deserializedThrowable = null;
       final Log4jLogEvent event = Log4jLogEvent.newBuilder() //
               .setLoggerName("testLogger") //
               .setLoggerFqcn(this.getClass().getName()) //
               .setLevel(Level.DEBUG) //
               .setMessage(new SimpleMessage("")) //
               .setThrown(deserializedThrowable) //
               .setThrownProxy(throwableProxy) //
               .setTimeMillis(0).build();
	final StringBuilder sb = new StringBuilder();
	converter.format(event, sb);
	final String result = sb.toString();
	assertTrue(result, result.contains(originalThrowable.getMessage()));
	assertTrue(result, result.contains(originalThrowable.getStackTrace()[0].getMethodName()));
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:21,代码来源:ExtendedThrowablePatternConverterTest.java


示例3: appendersCalled

import org.apache.logging.log4j.core.impl.ThrowableProxy; //导入依赖的package包/类
public void appendersCalled(LogEvent event) {
  ThrowableProxy throwableProxy = event.getThrownProxy();
  String throwable = (throwableProxy != null) ? throwableProxy.getName() : null;
  LogEventTracker.LogLevel level = LogEventTracker.LogLevel.valueOf(event.getLevel().toString());
  tracker.track(level, (throwableProxy != null), throwable);

}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:8,代码来源:Log4J2RuleHelper.java


示例4: format

import org.apache.logging.log4j.core.impl.ThrowableProxy; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void format(final LogEvent event, final StringBuilder toAppendTo) {
    ThrowableProxy proxy = null;
    if (event instanceof Log4jLogEvent) {
        proxy = ((Log4jLogEvent) event).getThrownProxy();
    }
    final Throwable throwable = event.getThrown();
    if (throwable != null && options.anyLines()) {
        if (proxy == null) {
            super.format(event, toAppendTo);
            return;
        }
        final String trace = proxy.getExtendedStackTrace(options.getPackages());
        final int len = toAppendTo.length();
        if (len > 0 && !Character.isWhitespace(toAppendTo.charAt(len - 1))) {
            toAppendTo.append(" ");
        }
        if (!options.allLines() || !Constants.LINE_SEP.equals(options.getSeparator())) {
            final StringBuilder sb = new StringBuilder();
            final String[] array = trace.split(Constants.LINE_SEP);
            final int limit = options.minLines(array.length) - 1;
            for (int i = 0; i <= limit; ++i) {
                sb.append(array[i]);
                if (i < limit) {
                    sb.append(options.getSeparator());
                }
            }
            toAppendTo.append(sb.toString());

        } else {
            toAppendTo.append(trace);
        }
    }
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:38,代码来源:ExtendedThrowablePatternConverter.java


示例5: format

import org.apache.logging.log4j.core.impl.ThrowableProxy; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void format(final LogEvent event, final StringBuilder toAppendTo) {
    ThrowableProxy proxy = null;
    if (event instanceof Log4jLogEvent) {
        proxy = ((Log4jLogEvent) event).getThrownProxy();
    }
    final Throwable throwable = event.getThrown();
    if (throwable != null && options.anyLines()) {
        if (proxy == null) {
            super.format(event, toAppendTo);
            return;
        }
        final String trace = proxy.getRootCauseStackTrace(options.getPackages());
        final int len = toAppendTo.length();
        if (len > 0 && !Character.isWhitespace(toAppendTo.charAt(len - 1))) {
            toAppendTo.append(" ");
        }
        if (!options.allLines() || !Constants.LINE_SEP.equals(options.getSeparator())) {
            final StringBuilder sb = new StringBuilder();
            final String[] array = trace.split(Constants.LINE_SEP);
            final int limit = options.minLines(array.length) - 1;
            for (int i = 0; i <= limit; ++i) {
                sb.append(array[i]);
                if (i < limit) {
                    sb.append(options.getSeparator());
                }
            }
            toAppendTo.append(sb.toString());

        } else {
            toAppendTo.append(trace);
        }
    }
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:38,代码来源:RootThrowablePatternConverter.java


示例6: format

import org.apache.logging.log4j.core.impl.ThrowableProxy; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void format(final LogEvent event, final StringBuilder toAppendTo) {
    final ThrowableProxy proxy = event.getThrownProxy();
    final Throwable throwable = event.getThrown();
    if (throwable != null && options.anyLines()) {
        if (proxy == null) {
            super.format(event, toAppendTo);
            return;
        }
        final String trace = proxy.getCauseStackTraceAsString(options.getIgnorePackages(), options.getTextRenderer(), getSuffix(event), options.getSeparator());
        final int len = toAppendTo.length();
        if (len > 0 && !Character.isWhitespace(toAppendTo.charAt(len - 1))) {
            toAppendTo.append(' ');
        }
        if (!options.allLines() || !Strings.LINE_SEPARATOR.equals(options.getSeparator())) {
            final StringBuilder sb = new StringBuilder();
            final String[] array = trace.split(Strings.LINE_SEPARATOR);
            final int limit = options.minLines(array.length) - 1;
            for (int i = 0; i <= limit; ++i) {
                sb.append(array[i]);
                if (i < limit) {
                    sb.append(options.getSeparator());
                }
            }
            toAppendTo.append(sb.toString());

        } else {
            toAppendTo.append(trace);
        }
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:35,代码来源:RootThrowablePatternConverter.java


示例7: setupModule

import org.apache.logging.log4j.core.impl.ThrowableProxy; //导入依赖的package包/类
void setupModule(final SetupContext context, final boolean includeStacktrace, final boolean stacktraceAsString) {
    // JRE classes: we cannot edit those with Jackson annotations
    context.setMixInAnnotations(StackTraceElement.class, StackTraceElementMixIn.class);
    // Log4j API classes: we do not want to edit those with Jackson annotations because the API module should not depend on Jackson.
    context.setMixInAnnotations(Marker.class, MarkerMixIn.class);
    context.setMixInAnnotations(Level.class, LevelMixIn.class);
    context.setMixInAnnotations(Instant.class, InstantMixIn.class);
    context.setMixInAnnotations(LogEvent.class, LogEventWithContextListMixIn.class);
    // Log4j Core classes: we do not want to bring in Jackson at runtime if we do not have to.
    context.setMixInAnnotations(ExtendedStackTraceElement.class, ExtendedStackTraceElementMixIn.class);
    context.setMixInAnnotations(ThrowableProxy.class,
            includeStacktrace ? (stacktraceAsString ? ThrowableProxyWithStacktraceAsStringMixIn.class : ThrowableProxyMixIn.class ) : ThrowableProxyWithoutStacktraceMixIn.class);
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:14,代码来源:Initializers.java


示例8: testSerializationDeserialization

import org.apache.logging.log4j.core.impl.ThrowableProxy; //导入依赖的package包/类
@Test
public void testSerializationDeserialization() throws IOException, ClassNotFoundException {
    final RingBufferLogEvent evt = new RingBufferLogEvent();
    final String loggerName = "logger.name";
    final Marker marker = null;
    final String fqcn = "f.q.c.n";
    final Level level = Level.TRACE;
    final Message data = new SimpleMessage("message");
    final Throwable t = new InternalError("not a real error");
    final ContextStack contextStack = null;
    final String threadName = "main";
    final StackTraceElement location = null;
    evt.setValues(null, loggerName, marker, fqcn, level, data, t, (StringMap) evt.getContextData(),
            contextStack, -1, threadName, -1, location,
            new FixedPreciseClock(12345, 678), new DummyNanoClock(1));
    ((StringMap) evt.getContextData()).putValue("key", "value");

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ObjectOutputStream out = new ObjectOutputStream(baos);
    out.writeObject(evt);

    final ObjectInputStream in = new FilteredObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
    final RingBufferLogEvent other = (RingBufferLogEvent) in.readObject();
    assertEquals(loggerName, other.getLoggerName());
    assertEquals(marker, other.getMarker());
    assertEquals(fqcn, other.getLoggerFqcn());
    assertEquals(level, other.getLevel());
    assertEquals(data, other.getMessage());
    assertNull("null after serialization", other.getThrown());
    assertEquals(new ThrowableProxy(t), other.getThrownProxy());
    assertEquals(evt.getContextData(), other.getContextData());
    assertEquals(contextStack, other.getContextStack());
    assertEquals(threadName, other.getThreadName());
    assertEquals(location, other.getSource());
    assertEquals(12345, other.getTimeMillis());
    assertEquals(678, other.getInstant().getNanoOfMillisecond());
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:38,代码来源:RingBufferLogEventTest.java


示例9: createLogEvent

import org.apache.logging.log4j.core.impl.ThrowableProxy; //导入依赖的package包/类
/**
 * @return a log event that uses all the bells and whistles, features, nooks and crannies
 */
static Log4jLogEvent createLogEvent() {
    final Marker cMarker = MarkerManager.getMarker("Marker1");
    final Marker pMarker1 = MarkerManager.getMarker("ParentMarker1");
    final Marker pMarker2 = MarkerManager.getMarker("ParentMarker2");
    final Marker gfMarker = MarkerManager.getMarker("GrandFatherMarker");
    final Marker gmMarker = MarkerManager.getMarker("GrandMotherMarker");
    cMarker.addParents(pMarker1);
    cMarker.addParents(pMarker2);
    pMarker1.addParents(gmMarker);
    pMarker1.addParents(gfMarker);
    final Exception sourceHelper = new Exception();
    sourceHelper.fillInStackTrace();
    final Exception cause = new NullPointerException("testNPEx");
    sourceHelper.fillInStackTrace();
    final StackTraceElement source = sourceHelper.getStackTrace()[0];
    final IOException ioException = new IOException("testIOEx", cause);
    ioException.addSuppressed(new IndexOutOfBoundsException("I am suppressed exception 1"));
    ioException.addSuppressed(new IndexOutOfBoundsException("I am suppressed exception 2"));
    final ThrowableProxy throwableProxy = new ThrowableProxy(ioException);
    final Map<String, String> contextMap = new HashMap<>();
    contextMap.put("MDC.A", "A_Value");
    contextMap.put("MDC.B", "B_Value");
    final DefaultThreadContextStack contextStack = new DefaultThreadContextStack(true);
    contextStack.clear();
    contextStack.push("stack_msg1");
    contextStack.add("stack_msg2");
    final Log4jLogEvent expected = Log4jLogEvent.newBuilder() //
            .setLoggerName("a.B") //
            .setMarker(cMarker) //
            .setLoggerFqcn("f.q.c.n") //
            .setLevel(Level.DEBUG) //
            .setMessage(new SimpleMessage("Msg")) //
            .setThrown(ioException) //
            .setThrownProxy(throwableProxy) //
            .setContextMap(contextMap) //
            .setContextStack(contextStack) //
            .setThreadName("MyThreadName") //
            .setSource(source) //
            .setTimeMillis(1).build();
    // validate event?
    return expected;
}
 
开发者ID:savantly-net,项目名称:log4j2-extended-jsonlayout,代码行数:46,代码来源:LogEventFixtures.java


示例10: format

import org.apache.logging.log4j.core.impl.ThrowableProxy; //导入依赖的package包/类
private final String format(final LogEvent event) {
	final StringBuilder sb = getStringBuilder();
	if (complete && eventCount > 0) {
		sb.append(", ");
	}
	sb.append('{');
	// Internal Info
	json(sb, "layout.version", LAYOUT_VERSION);
	json(sb, "layout.start", layoutStartTime);
	json(sb, "layout.sequence", layoutSequence.incrementAndGet());
	// Basic Info
	json(sb, "timestamp", event.getTimeMillis());
	json(sb, "thread", event.getThreadName());
	json(sb, "threadId", event.getThreadId());
	json(sb, "level", event.getLevel().toString());
	json(sb, "logger", event.getLoggerName());
	// Caller info
	if (locationInfo) {
		final StackTraceElement source = event.getSource();
		json(sb, "source");
		sb.append('{');
		json(sb, "class", source.getClassName());
		json(sb, "method", source.getMethodName());
		json(sb, "file", source.getFileName());
		json(sb, "line", source.getLineNumber());
		sb.setLength(sb.length() - 1);
		sb.append('}').append(',');
	}
	// Diagnostic Context
	if (properties) {
		if (!event.getContextStack().isEmpty()) {
			json(sb, "ndc", event.getContextStack().asList());
		}
		if (!event.getContextData().isEmpty()) {
			json(sb, "mdc", event.getContextData().toMap());
		}
	}
	// Additional Fields
	for (int i = 0; i < additionalFields.length; i++) {
		final KeyValuePair kv = additionalFields[i];
		final String key = kv.getKey();
		final String value = kv.getValue();
		final String iv = interpolator.lookup(event, value);
		if (iv != null) {
			json(sb, (key != null) ? key : value, iv);
		}
	}
	// Message
	json(sb, "msg", event.getMessage().getFormattedMessage());
	// Exceptions
	if (event.getThrownProxy() != null) {
		final ThrowableProxy throwableInfo = event.getThrownProxy();
		final Throwable t = throwableInfo.getThrowable();
		final String exClass = t.getClass().getCanonicalName();
		if (exClass != null) {
			json(sb, "exception", exClass);
		}
		final String exMsg = t.getMessage();
		if (exMsg != null) {
			json(sb, "cause", exMsg);
		}
		// TODO: Change pure string to complex list/maps of stacktraces?
		final String stackTrace = throwableInfo.getExtendedStackTraceAsString("");
		if (stackTrace != null) {
			json(sb, "stacktrace", stackTrace);
		}
	}
	sb.setLength(sb.length() - 1);
	sb.append('}').append(eol);
	return sb.toString();
}
 
开发者ID:ggrandes,项目名称:log4j2-simplejson,代码行数:72,代码来源:SimpleJSONLayout.java


示例11: processLogEvent

import org.apache.logging.log4j.core.impl.ThrowableProxy; //导入依赖的package包/类
private Message processLogEvent(LogEvent logEvent) {
    final String formattedMessage = logEvent.getMessage().getFormattedMessage();
    final DateTime timestamp = new DateTime(logEvent.getTimeMillis(), DateTimeZone.UTC);
    final Message message = new Message(formattedMessage, hostname, timestamp);

    final Level level = logEvent.getLevel();
    message.addField(Message.FIELD_LEVEL, Severity.getSeverity(level).getCode());
    message.addField("log4j_level", level.name());
    message.addField("log4j_level_int", level.intLevel());

    message.addField("node_id", nodeId);
    if (clusterId != null) {
        message.addField("cluster_id", clusterId);
    }
    message.addField("logger_name", logEvent.getLoggerName());
    message.addField("thread_id", logEvent.getThreadId());
    message.addField("thread_name", logEvent.getThreadName());
    message.addField("thread_priority", logEvent.getThreadPriority());
    message.addField("timestamp_nanos", logEvent.getNanoTime());

    final Marker marker = logEvent.getMarker();
    if (marker != null) {
        message.addField("marker", marker.getName());
    }

    if (includeThreadContext) {
        logEvent.getContextData().forEach((k, v ) -> message.addField("context_" + k, v));

        // Guard against https://issues.apache.org/jira/browse/LOG4J2-1530
        final ThreadContext.ContextStack contextStack = logEvent.getContextStack();
        if (contextStack != null) {
            final List<String> contextStackItems = contextStack.asList();
            if (contextStackItems != null && !contextStackItems.isEmpty()) {
                message.addField("context_stack", contextStackItems);
            }
        }
    }

    if (includeSource) {
        final StackTraceElement source = logEvent.getSource();
        if (source != null) {
            message.addField("source_file_name", source.getFileName());
            message.addField("source_method_name", source.getMethodName());
            message.addField("source_class_name", source.getClassName());
            message.addField("source_line_number", source.getLineNumber());
        }
    }

    final ThrowableProxy throwableProxy = logEvent.getThrownProxy();
    if (includeStackTrace && throwableProxy != null) {
        final String stackTrace;
        if (includeExceptionCause) {
            stackTrace = throwableProxy.getExtendedStackTraceAsString("");
        } else {
            stackTrace = throwableProxy.getCauseStackTraceAsString("");
        }

        message.addField("exception_class", throwableProxy.getName());
        message.addField("exception_message", throwableProxy.getMessage());
        message.addField("exception_stack_trace", stackTrace);
    }

    return message;
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-internal-logs,代码行数:65,代码来源:SerializedLogEventCodec.java


示例12: format

import org.apache.logging.log4j.core.impl.ThrowableProxy; //导入依赖的package包/类
/**
  * {@inheritDoc}
  */
 @Override
 public void format(final LogEvent event, final StringBuilder toAppendTo) {

 	
     final ThrowableProxy proxy = event.getThrownProxy();
     final Throwable throwable = event.getThrown();
     
     
     //xpipe code
     if(throwable != null){
  	if(ExceptionUtils.isSocketIoException(event.getThrown()) || ExceptionUtils.xpipeExceptionLogMessage(throwable)){
  		toAppendTo.append("," + throwable.getClass() + ":" + throwable.getMessage());
  		return;
  	}
  	
  	String extra = ExceptionUtils.extractExtraMessage(throwable);
  	if(extra != null){
	toAppendTo.append(String.format("\n[%s]", extra));
}
     }

     if ((throwable != null || proxy != null) && options.anyLines()) {
         if (proxy == null) {
             super.format(event, toAppendTo);
             return;
         }
         final String extStackTrace = proxy.getExtendedStackTraceAsString(options.getPackages());
         final int len = toAppendTo.length();
         if (len > 0 && !Character.isWhitespace(toAppendTo.charAt(len - 1))) {
             toAppendTo.append(' ');
         }
         if (!options.allLines() || !Constants.LINE_SEPARATOR.equals(options.getSeparator())) {
             final StringBuilder sb = new StringBuilder();
             final String[] array = extStackTrace.split(Constants.LINE_SEPARATOR);
             final int limit = options.minLines(array.length) - 1;
             for (int i = 0; i <= limit; ++i) {
                 sb.append(array[i]);
                 if (i < limit) {
                     sb.append(options.getSeparator());
                 }
             }
             toAppendTo.append(sb.toString());

         } else {
             toAppendTo.append(extStackTrace);
         }
     }
 }
 
开发者ID:ctripcorp,项目名称:x-pipe,代码行数:52,代码来源:XPipeThrowablePatternConverter.java


示例13: getThrownProxy

import org.apache.logging.log4j.core.impl.ThrowableProxy; //导入依赖的package包/类
/**
 * Returns the Throwable associated with the event, if any.
 * @return the Throwable.
 */
@Override
public ThrowableProxy getThrownProxy() {
    return event.getThrownProxy();
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:9,代码来源:FlumeEvent.java


示例14: getThrownProxy

import org.apache.logging.log4j.core.impl.ThrowableProxy; //导入依赖的package包/类
@Override
@Transient
public ThrowableProxy getThrownProxy() {
    return this.getWrappedEvent().getThrownProxy();
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:6,代码来源:TestBaseEntity.java


示例15: getThrownProxy

import org.apache.logging.log4j.core.impl.ThrowableProxy; //导入依赖的package包/类
@Override
public ThrowableProxy getThrownProxy() {
    return null;
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:5,代码来源:AbstractLogEvent.java


示例16: getSuppressedProxies

import org.apache.logging.log4j.core.impl.ThrowableProxy; //导入依赖的package包/类
@JsonProperty(JsonConstants.ELT_SUPPRESSED)
@JacksonXmlElementWrapper(namespace = XmlConstants.XML_NAMESPACE, localName = XmlConstants.ELT_SUPPRESSED)
@JacksonXmlProperty(namespace = XmlConstants.XML_NAMESPACE, localName = XmlConstants.ELT_SUPPRESSED_ITEM)
public abstract ThrowableProxy[] getSuppressedProxies();
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:5,代码来源:ThrowableProxyWithoutStacktraceMixIn.java


示例17: getThrownProxy

import org.apache.logging.log4j.core.impl.ThrowableProxy; //导入依赖的package包/类
@JsonProperty(JsonConstants.ELT_THROWN)
@JacksonXmlProperty(namespace = XmlConstants.XML_NAMESPACE, localName = XmlConstants.ELT_THROWN)
@Override
public abstract ThrowableProxy getThrownProxy();
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:5,代码来源:LogEventWithContextListMixIn.java


示例18: createLogEvent

import org.apache.logging.log4j.core.impl.ThrowableProxy; //导入依赖的package包/类
/**
 * @return a log event that uses all the bells and whistles, features, nooks and crannies
 */
static Log4jLogEvent createLogEvent() {
    final Marker cMarker = MarkerManager.getMarker("Marker1");
    final Marker pMarker1 = MarkerManager.getMarker("ParentMarker1");
    final Marker pMarker2 = MarkerManager.getMarker("ParentMarker2");
    final Marker gfMarker = MarkerManager.getMarker("GrandFatherMarker");
    final Marker gmMarker = MarkerManager.getMarker("GrandMotherMarker");
    cMarker.addParents(pMarker1);
    cMarker.addParents(pMarker2);
    pMarker1.addParents(gmMarker);
    pMarker1.addParents(gfMarker);
    final Exception sourceHelper = new Exception();
    sourceHelper.fillInStackTrace();
    final Exception cause = new NullPointerException("testNPEx");
    sourceHelper.fillInStackTrace();
    final StackTraceElement source = sourceHelper.getStackTrace()[0];
    final IOException ioException = new IOException("testIOEx", cause);
    ioException.addSuppressed(new IndexOutOfBoundsException("I am suppressed exception 1"));
    ioException.addSuppressed(new IndexOutOfBoundsException("I am suppressed exception 2"));
    final ThrowableProxy throwableProxy = new ThrowableProxy(ioException);
    final StringMap contextData = ContextDataFactory.createContextData();
    contextData.putValue("MDC.A", "A_Value");
    contextData.putValue("MDC.B", "B_Value");
    final DefaultThreadContextStack contextStack = new DefaultThreadContextStack(true);
    contextStack.clear();
    contextStack.push("stack_msg1");
    contextStack.add("stack_msg2");
    final Log4jLogEvent expected = Log4jLogEvent.newBuilder() //
            .setLoggerName("a.B") //
            .setMarker(cMarker) //
            .setLoggerFqcn("f.q.c.n") //
            .setLevel(Level.DEBUG) //
            .setMessage(new SimpleMessage("Msg")) //
            .setThrown(ioException) //
            .setThrownProxy(throwableProxy) //
            .setContextData(contextData) //
            .setContextStack(contextStack) //
            .setThreadName("MyThreadName") //
            .setSource(source) //
            .setTimeMillis(1).build();
    // validate event?
    return expected;
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:46,代码来源:LogEventFixtures.java


示例19: getThrownProxy

import org.apache.logging.log4j.core.impl.ThrowableProxy; //导入依赖的package包/类
/**
 * Gets the exception logged. Annotated with {@code @Convert(converter = ThrowableAttributeConverter.class)}.
 *
 * @return the exception logged.
 * @see ThrowableAttributeConverter
 */
@Override
@Transient
public ThrowableProxy getThrownProxy() {
    return this.getWrappedEvent().getThrownProxy();
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:12,代码来源:BasicLogEventEntity.java


示例20: getThrownProxy

import org.apache.logging.log4j.core.impl.ThrowableProxy; //导入依赖的package包/类
/**
 * Gets throwable proxy associated with logging request.
 *
 * @return throwable, may be null.
 */
ThrowableProxy getThrownProxy();
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:7,代码来源:LogEvent.java



注:本文中的org.apache.logging.log4j.core.impl.ThrowableProxy类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CtConstructorCall类代码示例发布时间:2022-05-23
下一篇:
Java WFSTCompletionLookup类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap