diff --git a/pom.xml b/pom.xml index a4aba06e..a3917191 100644 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,7 @@ 6.0.0 - 5.12.2 + 6.0.3 3.27.7 5.23.0 1.37 @@ -90,7 +90,7 @@ 3.6.2 3.4.0 3.5.0 - 2.22.2 + 3.5.3 3.6.3 3.12.0 3.2.8 diff --git a/sample-spring-boot/pom.xml b/sample-spring-boot/pom.xml index 8c82fd76..7e7b0bb8 100644 --- a/sample-spring-boot/pom.xml +++ b/sample-spring-boot/pom.xml @@ -15,7 +15,7 @@ UTF-8 - 3.5.12 + 4.0.5 1.5 0bzhBRNUXBR5 @@ -103,12 +103,12 @@ org.springframework.boot spring-boot-starter-test test - - - com.sap.hcp.cf.logging - cf-java-logging-support-servlet-dynlog-jwt - ${project.version} - compile + + + com.vaadin.external.google + android-json + + @@ -185,7 +185,7 @@ org.apache.logging.log4j - log4j-slf4j-impl + log4j-slf4j2-impl ${log4j2.version} @@ -207,7 +207,7 @@ org.apache.logging.log4j - log4j-slf4j-impl + log4j-slf4j2-impl org.apache.logging.log4j diff --git a/sample-spring-boot/src/main/java/com/sap/hcp/cf/logging/sample/springboot/SampleAppSpringBootApplication.java b/sample-spring-boot/src/main/java/com/sap/hcp/cf/logging/sample/springboot/SampleAppSpringBootApplication.java index 4fc6dbb2..cb0c28ef 100644 --- a/sample-spring-boot/src/main/java/com/sap/hcp/cf/logging/sample/springboot/SampleAppSpringBootApplication.java +++ b/sample-spring-boot/src/main/java/com/sap/hcp/cf/logging/sample/springboot/SampleAppSpringBootApplication.java @@ -7,12 +7,10 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.core.Ordered; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; import java.time.Clock; @SpringBootApplication -@EnableWebMvc public class SampleAppSpringBootApplication { public static void main(String[] args) { diff --git a/sample-spring-boot/src/main/java/com/sap/hcp/cf/logging/sample/springboot/controller/LogController.java b/sample-spring-boot/src/main/java/com/sap/hcp/cf/logging/sample/springboot/controller/LogController.java index 7cdbcdb8..963ea4bf 100644 --- a/sample-spring-boot/src/main/java/com/sap/hcp/cf/logging/sample/springboot/controller/LogController.java +++ b/sample-spring-boot/src/main/java/com/sap/hcp/cf/logging/sample/springboot/controller/LogController.java @@ -34,24 +34,29 @@ public ResponseEntity generateLog(@PathVariable("logger") String loggerN defaultValue = DEFAULT_LOG_MESSAGE) String message) { Logger logger = LoggerFactory.getLogger(loggerName); switch (logLevel.toLowerCase()) { - case "error": + case "error" -> { logger.error(message); return ResponseEntity.ok().body("Generated error log with message: \"" + message + "\"."); - case "warn": - case "warning": + } + case "warn", "warning" -> { logger.warn(message); return ResponseEntity.ok().body("Generated warn log with message: \"" + message + "\"."); - case "info": - case "informational": + } + case "info", "informational" -> { logger.info(message); return ResponseEntity.ok().body("Generated info log with message: \"" + message + "\"."); - case "debug": + } + case "debug" -> { logger.debug(message); return ResponseEntity.ok().body("Generated debug log with message: \"" + message + "\"."); - case "trace": + } + case "trace" -> { logger.trace(message); return ResponseEntity.ok().body("Generated trace log with message: \"" + message + "\"."); } - return ResponseEntity.badRequest().body("Unknows log level \"" + logLevel + "\"."); + default -> { + return ResponseEntity.badRequest().body("Unknows log level \"" + logLevel + "\"."); + } + } } } diff --git a/sample-spring-boot/src/main/java/com/sap/hcp/cf/logging/sample/springboot/security/SecurityConfiguration.java b/sample-spring-boot/src/main/java/com/sap/hcp/cf/logging/sample/springboot/security/SecurityConfiguration.java index 2b56aa48..4b082106 100644 --- a/sample-spring-boot/src/main/java/com/sap/hcp/cf/logging/sample/springboot/security/SecurityConfiguration.java +++ b/sample-spring-boot/src/main/java/com/sap/hcp/cf/logging/sample/springboot/security/SecurityConfiguration.java @@ -23,7 +23,8 @@ public class SecurityConfiguration { public UserDetailsService userDetails(@Autowired PasswordEncoder encoder, @Value("${auth.basic.username:user}") String username, @Value("${auth.basic.password:secret}") String password) { - UserDetails user = User.withUsername(username).password(encoder.encode(password)).roles(Roles.USER).build(); + UserDetails user = + User.builder().username(username).password(encoder.encode(password)).roles(Roles.USER).build(); return new InMemoryUserDetailsManager(user); } diff --git a/sample-spring-boot/src/main/java/com/sap/hcp/cf/logging/sample/springboot/statistics/StatisticsContextFieldSupplier.java b/sample-spring-boot/src/main/java/com/sap/hcp/cf/logging/sample/springboot/statistics/StatisticsContextFieldSupplier.java index e6a5eb43..672dc1e7 100644 --- a/sample-spring-boot/src/main/java/com/sap/hcp/cf/logging/sample/springboot/statistics/StatisticsContextFieldSupplier.java +++ b/sample-spring-boot/src/main/java/com/sap/hcp/cf/logging/sample/springboot/statistics/StatisticsContextFieldSupplier.java @@ -2,7 +2,6 @@ import com.sap.hcp.cf.logging.common.serialization.ContextFieldSupplier; -import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicLong; @@ -10,16 +9,11 @@ public class StatisticsContextFieldSupplier implements ContextFieldSupplier { private static final String KEY = "message_count"; - private static AtomicLong count = new AtomicLong(); + private static final AtomicLong count = new AtomicLong(); - @SuppressWarnings("serial") @Override public Map get() { - return new HashMap() { - { - put(KEY, count.incrementAndGet()); - } - }; + return Map.of(KEY, count.incrementAndGet()); } } diff --git a/sample-spring-boot/src/main/resources/logback.xml b/sample-spring-boot/src/main/resources/logback.xml index c3ca82ee..739823a4 100644 --- a/sample-spring-boot/src/main/resources/logback.xml +++ b/sample-spring-boot/src/main/resources/logback.xml @@ -14,14 +14,6 @@ - - - %d %-5level [%thread] %logger{0} [%mdc]>: %msg - %replace(%xEx){'\n', ' | '}%nopex%n - - -