Skip to content

s50600822/logstash_tut

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

prequesite

  • log stash installed
brew tap elastic/tap
brew install elastic/tap/logstash-full
  • elastic ready to serve
# can get it from [email protected]:s50600822/conductor-cheat.git, under conductor-cheat/es
docker-compose-up up

how to play

Alt Text

regexp can be verified

https://regex101.com/r/jvusnc/1

Ref

##MDC pattern k1=v1, k2=v2 Logback

    private String outputMDCForAllKeys(Map<String, String> mdcPropertyMap) {
        StringBuilder buf = new StringBuilder();
        boolean first = true;
        for (Map.Entry<String, String> entry : mdcPropertyMap.entrySet()) {
            if (first) {
                first = false;
            } else {
                buf.append(", ");
            }
            // format: key0=value0, key1=value1
            buf.append(entry.getKey()).append('=').append(entry.getValue());
        }
        return buf.toString();
    }

##log4j {{k1=v1},{k2=v2}}

    public void format(final LogEvent event, final StringBuilder toAppendTo) {
        if (key == null) {
            // if there is no additional options, we output every single Key/Value pair for the MDC
            toAppendTo.append('{');
            event.getContextData().forEach(APPEND_EACH, toAppendTo);
            toAppendTo.append('}');
        } else {
            // otherwise they just want a single key output
            final Object val = event.getContextData().getValue(key);
            if (val != null) {
                toAppendTo.append(val);
            }
        }
    }

    private static TriConsumer<String, Object, StringBuilder> APPEND_EACH = new TriConsumer<String, Object, StringBuilder>() {
        @Override
        public void accept(final String key, final Object value, final StringBuilder toAppendTo) {
            toAppendTo.append('{').append(key).append(',').append(value).append('}');
        }
    };

About

woot!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages