diff --git a/src/main/java/biz/paluch/logging/gelf/GelfMessageAssembler.java b/src/main/java/biz/paluch/logging/gelf/GelfMessageAssembler.java index 90b047cc9..599c24bb0 100644 --- a/src/main/java/biz/paluch/logging/gelf/GelfMessageAssembler.java +++ b/src/main/java/biz/paluch/logging/gelf/GelfMessageAssembler.java @@ -116,6 +116,11 @@ public void initialize(PropertyProvider propertyProvider) { if (messageSize != null) { maximumMessageSize = Integer.parseInt(messageSize); } + + String timestampPattern = propertyProvider.getProperty(PropertyProvider.PROPERTY_TIMESTAMP_PATTERN); + if (timestampPattern != null && !"".equals(timestampPattern)) { + this.timestampPattern = timestampPattern; + } } /** diff --git a/src/main/java/biz/paluch/logging/gelf/PropertyProvider.java b/src/main/java/biz/paluch/logging/gelf/PropertyProvider.java index 10c109413..930024d8f 100644 --- a/src/main/java/biz/paluch/logging/gelf/PropertyProvider.java +++ b/src/main/java/biz/paluch/logging/gelf/PropertyProvider.java @@ -33,6 +33,7 @@ public interface PropertyProvider { String PROPERTY_ADDITIONAL_FIELD_TYPE = "additionalFieldType."; String PROPERTY_ADDITIONAL_FIELDS = "additionalFields"; String PROPERTY_ADDITIONAL_FIELD_TYPES = "additionalFieldTypes"; + String PROPERTY_TIMESTAMP_PATTERN = "timestampPattern"; String PROPERTY_FILTER = "filter"; String PROPERTY_LEVEL = "level"; diff --git a/src/test/java/biz/paluch/logging/gelf/jul/GelfLogHandlerUnitTests.java b/src/test/java/biz/paluch/logging/gelf/jul/GelfLogHandlerUnitTests.java index 9da187927..1b40b1e49 100644 --- a/src/test/java/biz/paluch/logging/gelf/jul/GelfLogHandlerUnitTests.java +++ b/src/test/java/biz/paluch/logging/gelf/jul/GelfLogHandlerUnitTests.java @@ -15,7 +15,7 @@ public class GelfLogHandlerUnitTests { private static final String HOST = "host"; private static final int GRAYLOG_PORT = 1; private static final int MAXIMUM_MESSAGE_SIZE = 1234; - private static final String TIMESTAMP_PATTERN = "yyyy-MM-dd HH:mm:ss,SSSS"; + private static final String TIMESTAMP_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"; @Test public void testSameFieldsGelfLogHandler() { @@ -27,6 +27,7 @@ public void testSameFieldsGelfLogHandler() { sut.setGraylogHost(HOST); sut.setGraylogPort(GRAYLOG_PORT); sut.setMaximumMessageSize(MAXIMUM_MESSAGE_SIZE); + sut.setTimestampPattern(TIMESTAMP_PATTERN); sut.flush(); diff --git a/src/test/resources/jul/test-logging.properties b/src/test/resources/jul/test-logging.properties index f74fffa4f..2162115a1 100644 --- a/src/test/resources/jul/test-logging.properties +++ b/src/test/resources/jul/test-logging.properties @@ -8,7 +8,7 @@ biz.paluch.logging.gelf.jul.GelfLogHandler.facility=java-test biz.paluch.logging.gelf.jul.GelfLogHandler.version=1.1 biz.paluch.logging.gelf.jul.GelfLogHandler.extractStackTrace=true biz.paluch.logging.gelf.jul.GelfLogHandler.filterStackTrace=true -biz.paluch.logging.gelf.jul.GelfLogHandler.timestampPattern=yyyy-MM-dd HH:mm:ss,SSSS +biz.paluch.logging.gelf.jul.GelfLogHandler.timestampPattern=yyyy-MM-dd'T'HH:mm:ss.SSSZ biz.paluch.logging.gelf.jul.GelfLogHandler.maximumMessageSize=8192 biz.paluch.logging.gelf.jul.GelfLogHandler.additionalFields=fieldName1=fieldValue1,fieldName2=fieldValue2 biz.paluch.logging.gelf.jul.GelfLogHandler.additionalField.0=fieldName3=fieldValue3