Java Code Examples for ch.qos.logback.classic.spi.ILoggingEvent#getLoggerContextVO()

The following examples show how to use ch.qos.logback.classic.spi.ILoggingEvent#getLoggerContextVO() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AwsCWEventDump.java    From cloudwatch-logback-appender with Apache License 2.0 5 votes vote down vote up
private void log(Collection<ILoggingEvent> aEvents) {
    if(dateFormat!=null) {
        dateHolder.setTime(System.currentTimeMillis());
        String newStreamName = streamName + "-" + dateFormat.format(dateHolder);

        if ( !newStreamName.equals(currentStreamName) ) {
            logContext.addInfo("stream name changed from '"+currentStreamName+"' to '"+newStreamName+"'");
            closeStream();
            openStream(newStreamName);
        }
    }
    else if (awsLogs==null) {
        closeStream();
        openStream(streamName);
    }

    Collection<InputLogEvent> events =  new ArrayList<>(aEvents.size());
    for(ILoggingEvent event : aEvents) {
        if(event.getLoggerContextVO()!=null) {
            events.add(new InputLogEvent()
                    .withTimestamp(event.getTimeStamp())
                    .withMessage(layout.map(event)));
        }
    }

    try {
        nextToken = awsLogs.putLogEvents(
                logEventReq
                        .withSequenceToken(nextToken)
                        .withLogEvents(events)
        ).getNextSequenceToken();
    }
    catch(Exception e) {
        logContext.addError("Exception while adding log events.", e);
    }
}
 
Example 2
Source File: LogbackPropertyValueDiscriminator.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
@Override
public String getDiscriminatingValue(final ILoggingEvent event)
{
    final LoggerContextVO context = event.getLoggerContextVO();
    if (context != null && context.getPropertyMap() != null && context.getPropertyMap().get(_key) != null)
    {
        return context.getPropertyMap().get(_key);
    }
    return _defaultValue;
}
 
Example 3
Source File: RequestContextExportingAppender.java    From armeria with Apache License 2.0 5 votes vote down vote up
LoggingEventWrapper(ILoggingEvent event, Map<String, String> mdcPropertyMap) {
    this.event = event;
    this.mdcPropertyMap = mdcPropertyMap;

    final LoggerContextVO oldVo = event.getLoggerContextVO();
    if (oldVo != null) {
        vo = new LoggerContextVO(oldVo.getName(), mdcPropertyMap, oldVo.getBirthTime());
    } else {
        vo = null;
    }
}
 
Example 4
Source File: TcpSocketAppenderInterceptor.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
    MethodInterceptResult result) throws Throwable {
    ILoggingEvent event = (ILoggingEvent) allArguments[0];
    if (event != null && event.getLoggerContextVO() != null && event.getLoggerContextVO()
                                                                    .getPropertyMap() != null) {
        event.getLoggerContextVO().getPropertyMap().put("TID", ContextManager.getGlobalTraceId());
    }
}