Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.io.IOException;

import net.logstash.logback.fieldnames.LogstashCommonFieldNames;
import net.logstash.logback.fieldnames.LogstashFieldNames;

import ch.qos.logback.access.spi.IAccessEvent;
import ch.qos.logback.classic.spi.ILoggingEvent;
Expand Down Expand Up @@ -53,9 +52,7 @@ public void writeTo(JsonGenerator generator, Event event) throws IOException {

@Override
public void setFieldNames(LogstashCommonFieldNames fieldNames) {
if (fieldNames instanceof LogstashFieldNames) {
setFieldName(((LogstashFieldNames) fieldNames).getContext());
}
setFieldName(fieldNames.getContext());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public abstract class LogstashCommonFieldNames {
private String timestamp = FormattedTimestampJsonProvider.FIELD_TIMESTAMP;
private String version = LogstashVersionJsonProvider.FIELD_VERSION;
private String message = MessageJsonProvider.FIELD_MESSAGE;

private String context;

public String getTimestamp() {
return timestamp;
}
Expand All @@ -65,4 +66,23 @@ public String getMessage() {
public void setMessage(String message) {
this.message = message;
}

/**
* The name of the context object field.
* <p>
* If this returns {@code null}, then the context fields will be written inline at the root level of the JSON event
* output (e.g. as a sibling to all the other fields in this class).
* <p>
* If this returns non-null, then the context fields will be written inside an object with field name returned by
* this method.
*
* @return The name of the context object field.
*/
public String getContext() {
return context;
}

public void setContext(String context) {
this.context = context;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public class LogstashFieldNames extends LogstashCommonFieldNames {
private String rootStackTraceElementMethod = RootStackTraceElementJsonProvider.FIELD_METHOD_NAME;
private String tags = TagsJsonProvider.FIELD_TAGS;
private String mdc;
private String context;
private String arguments;
private String uuid = UuidProvider.FIELD_UUID;

Expand Down Expand Up @@ -163,22 +162,6 @@ public void setMdc(String mdc) {
this.mdc = mdc;
}

/**
* The name of the context object field.
* <p>
* If this returns null, then the context fields will be written inline at the root level of the JSON event output (e.g. as a sibling to all the other fields in this class).
* <p>
* If this returns non-null, then the context fields will be written inside an object with field name returned by this method
* @return The name of the context object field.
*/
public String getContext() {
return context;
}

public void setContext(String context) {
this.context = context;
}

/**
* The name of the arguments object field.
* <p>
Expand Down