Skip to content

Commit d729141

Browse files
authored
Support for Logback 1.1 (#88)
1 parent 4f9fd22 commit d729141

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

logback-ecs-encoder/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ECS Logback Encoder
22

3-
The minimum required logback version is 1.2.
3+
The minimum required logback version is 1.1.
44

55
## Step 1: add dependency
66

logback-ecs-encoder/src/main/java/co/elastic/logging/logback/EcsEncoder.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import co.elastic.logging.JsonUtils;
3434
import org.slf4j.Marker;
3535

36+
import java.io.IOException;
37+
import java.io.OutputStream;
3638
import java.nio.charset.Charset;
3739
import java.util.ArrayList;
3840
import java.util.Iterator;
@@ -48,6 +50,7 @@ public class EcsEncoder extends EncoderBase<ILoggingEvent> {
4850
private ThrowableProxyConverter throwableProxyConverter;
4951
private boolean includeOrigin;
5052
private final List<Pair> additionalFields = new ArrayList<Pair>();
53+
private OutputStream os;
5154

5255
@Override
5356
public byte[] headerBytes() {
@@ -61,6 +64,28 @@ public void start() {
6164
throwableProxyConverter.start();
6265
eventDataset = EcsJsonSerializer.computeEventDataset(eventDataset, serviceName);
6366
}
67+
/**
68+
* This method has been removed in logback 1.2.
69+
* To make this lib backwards compatible with logback 1.1 we have implement this method.
70+
*/
71+
public void init(OutputStream os) {
72+
this.os = os;
73+
}
74+
75+
/**
76+
* This method has been removed in logback 1.2.
77+
* To make this lib backwards compatible with logback 1.1 we have implement this method.
78+
*/
79+
public void doEncode(ILoggingEvent event) throws IOException {
80+
os.write(encode(event));
81+
}
82+
83+
/**
84+
* This method has been removed in logback 1.2.
85+
* To make this lib backwards compatible with logback 1.1 we have implement this method.
86+
*/
87+
public void close() throws IOException {
88+
}
6489

6590
@Override
6691
public byte[] encode(ILoggingEvent event) {

0 commit comments

Comments
 (0)