Skip to content

Commit fd360cf

Browse files
Merge pull request #26 from KarstenSchnitter/version-2.1.5
Version 2.1.5
2 parents 6ce8547 + 5ec03c6 commit fd360cf

File tree

14 files changed

+36
-20
lines changed

14 files changed

+36
-20
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ All in all, you should do the following:
2727
* adjust your logging configuration accordingly.
2828

2929

30-
Say, you want to make use of the *servlet filter* feature, then you need to add the following dependency to your POM with property `cf-logging-version` referring to the latest nexus version (currently `2.1.4`):
30+
Say, you want to make use of the *servlet filter* feature, then you need to add the following dependency to your POM with property `cf-logging-version` referring to the latest nexus version (currently `2.1.5`):
3131

3232
```xml
3333
<properties>
34-
<cf-logging-version>2.1.4</cf-logging-version>
34+
<cf-logging-version>2.1.5</cf-logging-version>
3535
</properties>
3636
```
3737

@@ -153,7 +153,7 @@ description about how to apply this feature can be found
153153

154154
## Logging Stacktraces
155155

156-
Stacktraces can be logged within one log message. Further details can be found
156+
Stacktraces can be logged within one log message. Further details can be found
157157
[here](https://github.com/SAP/cf-java-logging-support/wiki/Logging-Stack-Traces).
158158

159159
## Sample Application

cf-java-logging-support-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<parent>
3333
<groupId>com.sap.hcp.cf.logging</groupId>
3434
<artifactId>cf-java-logging-support-parent</artifactId>
35-
<version>2.1.4</version>
35+
<version>2.1.5</version>
3636
<relativePath>../pom.xml</relativePath>
3737
</parent>
3838
<build>

cf-java-logging-support-jersey/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<relativePath>../pom.xml</relativePath>
1010
<groupId>com.sap.hcp.cf.logging</groupId>
1111
<artifactId>cf-java-logging-support-parent</artifactId>
12-
<version>2.1.4</version>
12+
<version>2.1.5</version>
1313
</parent>
1414

1515
<name>cf-java-logging-support-jersey</name>

cf-java-logging-support-log4j2/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<relativePath>../pom.xml</relativePath>
1212
<groupId>com.sap.hcp.cf.logging</groupId>
1313
<artifactId>cf-java-logging-support-parent</artifactId>
14-
<version>2.1.4</version>
14+
<version>2.1.5</version>
1515
</parent>
1616

1717
<dependencies>

cf-java-logging-support-logback/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<relativePath>../pom.xml</relativePath>
1111
<groupId>com.sap.hcp.cf.logging</groupId>
1212
<artifactId>cf-java-logging-support-parent</artifactId>
13-
<version>2.1.4</version>
13+
<version>2.1.5</version>
1414
</parent>
1515

1616
<dependencies>

cf-java-logging-support-servlet/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<parent>
1010
<groupId>com.sap.hcp.cf.logging</groupId>
1111
<artifactId>cf-java-logging-support-parent</artifactId>
12-
<version>2.1.4</version>
12+
<version>2.1.5</version>
1313
<relativePath>../pom.xml</relativePath>
1414
</parent>
1515

cf-java-logging-support-servlet/src/main/java/com/sap/hcp/cf/logging/servlet/dynlog/DynamicLogLevelProcessor.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ public void copyDynamicLogLevelToMDC(HttpServletRequest httpRequest) {
4747
ALLOWED_DYNAMIC_LOGLEVELS.toString());
4848
}
4949
} catch (DynamicLogLevelException e) {
50-
LOGGER.error("DynamicLogLevelProcessor could not write dynamic log level to MDC", e);
50+
LOGGER.warn("DynamicLogLevelProcessor could not write dynamic log level to MDC", e);
5151
}
5252
}
5353
}
54+
55+
public void removeDynamicLogLevelFromMDC() {
56+
MDC.remove(DynamicLogLevelHelper.MDC_DYNAMIC_LOG_LEVEL_KEY);
57+
}
5458
}

cf-java-logging-support-servlet/src/main/java/com/sap/hcp/cf/logging/servlet/dynlog/TokenCreator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static void main(String[] args) throws NoSuchAlgorithmException, NoSuchPr
4444
// "TRACE", "DEBUG", "INFO", "WARN", "ERROR"
4545
String level = "TRACE";
4646
// Set a validity period in days
47-
int validityPeriodInDays = 2;
47+
long validityPeriodInDays = 2;
4848
// If available provide Base64 encoded private key here:
4949
String privateKey = "";
5050
// If available provide Base64 encoded private key here:

cf-java-logging-support-servlet/src/main/java/com/sap/hcp/cf/logging/servlet/dynlog/TokenDecoder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public DecodedJWT validateAndDecodeToken(String token) throws DynamicLogLevelExc
3636
throw new DynamicLogLevelException("Token provided to dynamically change the log-level on thread-level is outdated");
3737
}
3838
} catch (JWTVerificationException e) {
39-
throw new DynamicLogLevelException("Token could not be verified", e);
39+
// Exception is not attached to avoid logging of JWT token
40+
throw new DynamicLogLevelException("Token could not be verified");
4041
}
4142
}
4243
}

cf-java-logging-support-servlet/src/main/java/com/sap/hcp/cf/logging/servlet/filter/RequestLoggingFilter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void destroy() {
8585
private void doFilterRequest(HttpServletRequest httpRequest, HttpServletResponse httpResponse, FilterChain chain)
8686
throws IOException,
8787
ServletException {
88-
if (httpRequest.getHeader(dynLogEnvironment.getDynLogHeaderKey()) != null) {
88+
if (httpRequest.getHeader(dynLogEnvironment.getDynLogHeaderKey()) != null && dynamicLogLevelProcessor != null) {
8989
dynamicLogLevelProcessor.copyDynamicLogLevelToMDC(httpRequest);
9090
}
9191
/*
@@ -149,6 +149,10 @@ private void doFilterRequest(HttpServletRequest httpRequest, HttpServletResponse
149149
*/
150150
} finally {
151151
rr.close();
152+
153+
if (dynamicLogLevelProcessor != null) {
154+
dynamicLogLevelProcessor.removeDynamicLogLevelFromMDC();
155+
}
152156
}
153157
}
154158

0 commit comments

Comments
 (0)