Skip to content

Commit bbe7273

Browse files
authored
Add SilencedGelfTcpAppender to silence GELF connection issues (#17)
1 parent b786cd7 commit bbe7273

6 files changed

Lines changed: 59 additions & 22 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,30 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout code
14-
uses: actions/checkout@v3
14+
uses: actions/checkout@v4
1515
with:
1616
fetch-depth: 0
17+
1718
- name: Setup Java
18-
uses: actions/setup-java@v3
19+
uses: actions/setup-java@v4
1920
with:
2021
distribution: temurin
2122
java-version: 17
23+
2224
- name: Setup Gradle
23-
uses: gradle/gradle-build-action@v2
24-
with:
25-
gradle-version: 8.4
25+
uses: gradle/actions/setup-gradle@v3
26+
2627
- name: Run tests and generate reports
2728
run: ./gradlew testAndReport
29+
2830
- name: Run Sonar analysis
2931
env:
3032
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3133
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3234
run: ./gradlew sonar -x test --no-watch-fs
35+
3336
- name: Upload Artifact
34-
uses: actions/upload-artifact@v3
37+
uses: actions/upload-artifact@v4
3538
with:
3639
name: report
3740
path: build/reports/**
@@ -41,19 +44,21 @@ jobs:
4144
runs-on: ubuntu-latest
4245
needs: [test]
4346
steps:
44-
- uses: actions/checkout@v3
45-
- uses: actions/setup-java@v3
47+
- uses: actions/checkout@v4
48+
49+
- uses: actions/setup-java@v4
4650
with:
4751
distribution: temurin
4852
java-version: 17
53+
4954
- name: Setup Gradle
50-
uses: gradle/gradle-build-action@v2
51-
with:
52-
gradle-version: 8.4
55+
uses: gradle/actions/setup-gradle@v3
56+
5357
- name: Run build with Gradle Wrapper
5458
run: ./gradlew build -x test
59+
5560
- name: Upload Artifact
56-
uses: actions/upload-artifact@v3
61+
uses: actions/upload-artifact@v4
5762
with:
5863
name: jar
5964
path: build/libs/**

‎Dockerfile‎

Lines changed: 0 additions & 8 deletions
This file was deleted.

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Library providing basic generic functionality required by any HTTP web service.
1010

1111
```
1212
// https://mvnrepository.com/artifact/ee.bitweb/spring-core
13-
implementation group: 'ee.bitweb', name: 'spring-core', version: '3.1.0'
13+
implementation group: 'ee.bitweb', name: 'spring-core', version: '3.2.0'
1414
```
1515

1616
Review available versions in [Maven Central](https://mvnrepository.com/artifact/ee.bitweb/spring-core).

‎build.gradle‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ plugins {
1919
}
2020

2121
group 'ee.bitweb'
22-
version '3.1.0'
22+
version '3.2.0'
2323
java {
2424
sourceCompatibility = '17'
2525
}
@@ -79,6 +79,9 @@ dependencies {
7979
// https://mvnrepository.com/artifact/com.squareup.okhttp3/logging-interceptor
8080
compileOnly group: 'com.squareup.okhttp3', name: 'logging-interceptor', version: '4.12.0'
8181

82+
// https://mvnrepository.com/artifact/de.siegmar/logback-gelf
83+
compileOnly group: 'de.siegmar', name: 'logback-gelf', version: '6.0.1'
84+
8285
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web
8386
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: "${springBootVersion}"
8487

‎gradle.properties‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
systemProp.org.gradle.internal.publish.checksums.insecure=true
2+
org.gradle.welcome=never
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package ee.bitweb.core.logging;
2+
3+
import ch.qos.logback.classic.spi.ILoggingEvent;
4+
import de.siegmar.logbackgelf.GelfTcpAppender;
5+
import ee.bitweb.core.exception.CoreException;
6+
import lombok.extern.slf4j.Slf4j;
7+
8+
@Slf4j
9+
public class SilencedGelfTcpAppender extends GelfTcpAppender {
10+
11+
@Override
12+
protected void append(final ILoggingEvent event) {
13+
final byte[] binMessage = getEncoder().encode(event);
14+
15+
try {
16+
appendMessage(binMessage);
17+
} catch (CoreException ignored) {
18+
// Catching and ignoring CoreException which will be thrown if application can't connect to Graylog, because we don't want the application
19+
// to stop.
20+
}
21+
}
22+
23+
@Override
24+
protected void appendMessage(final byte[] messageToSend) {
25+
try {
26+
super.appendMessage(messageToSend);
27+
} catch (CoreException e) {
28+
throw new CoreException("Error sending GELF message", e);
29+
}
30+
}
31+
32+
@Override
33+
public void addError(String msg, Throwable ex) {
34+
throw new CoreException(msg, ex);
35+
}
36+
}

0 commit comments

Comments
 (0)