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
2 changes: 1 addition & 1 deletion logback-ecs-encoder/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ECS Logback Encoder

The minimum required logback version is 1.2.
The minimum required logback version is 1.1.

## Step 1: add dependency

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import co.elastic.logging.JsonUtils;
import org.slf4j.Marker;

import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Iterator;
Expand All @@ -48,6 +50,7 @@ public class EcsEncoder extends EncoderBase<ILoggingEvent> {
private ThrowableProxyConverter throwableProxyConverter;
private boolean includeOrigin;
private final List<Pair> additionalFields = new ArrayList<Pair>();
private OutputStream os;

@Override
public byte[] headerBytes() {
Expand All @@ -61,6 +64,28 @@ public void start() {
throwableProxyConverter.start();
eventDataset = EcsJsonSerializer.computeEventDataset(eventDataset, serviceName);
}
/**
* This method has been removed in logback 1.2.
* To make this lib backwards compatible with logback 1.1 we have implement this method.
*/
public void init(OutputStream os) {
this.os = os;
}

/**
* This method has been removed in logback 1.2.
* To make this lib backwards compatible with logback 1.1 we have implement this method.
*/
public void doEncode(ILoggingEvent event) throws IOException {
os.write(encode(event));
}

/**
* This method has been removed in logback 1.2.
* To make this lib backwards compatible with logback 1.1 we have implement this method.
*/
public void close() throws IOException {
}

@Override
public byte[] encode(ILoggingEvent event) {
Expand Down