Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<servlet.api.version>6.0.0</servlet.api.version>

<!-- Test dependencies -->
<junit.version>5.12.2</junit.version>
<junit.version>6.0.3</junit.version>
<assertj.version>3.27.7</assertj.version>
<mockito.version>5.23.0</mockito.version>
<jmh.version>1.37</jmh.version>
Expand All @@ -90,7 +90,7 @@
<enforcer.plugin.version>3.6.2</enforcer.plugin.version>
<source.plugin.version>3.4.0</source.plugin.version>
<jar.plugin.version>3.5.0</jar.plugin.version>
<surefire.plugin.version>2.22.2</surefire.plugin.version>
<surefire.plugin.version>3.5.3</surefire.plugin.version>
<exec.plugin.version>3.6.3</exec.plugin.version>
<javadoc.plugin.version>3.12.0</javadoc.plugin.version>
<gpg.plugin.version>3.2.8</gpg.plugin.version>
Expand Down
18 changes: 9 additions & 9 deletions sample-spring-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.boot.version>3.5.12</spring.boot.version>
<spring.boot.version>4.0.5</spring.boot.version>
<keytool.plugin.version>1.5</keytool.plugin.version>
<keystore.token.store_password>0bzhBRNUXBR5
</keystore.token.store_password>
Expand Down Expand Up @@ -103,12 +103,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sap.hcp.cf.logging</groupId>
<artifactId>cf-java-logging-support-servlet-dynlog-jwt</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down Expand Up @@ -185,7 +185,7 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<artifactId>log4j-slf4j2-impl</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
Expand All @@ -207,7 +207,7 @@
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<artifactId>log4j-slf4j2-impl</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,29 @@ public ResponseEntity<String> 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 + "\".");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,18 @@

import com.sap.hcp.cf.logging.common.serialization.ContextFieldSupplier;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;

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<String, Object> get() {
return new HashMap<String, Object>() {
{
put(KEY, count.incrementAndGet());
}
};
return Map.of(KEY, count.incrementAndGet());
}

}
8 changes: 0 additions & 8 deletions sample-spring-boot/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
<!-- <customFieldMdcKeyName>message_count</customFieldMdcKeyName> -->
</encoder>
</appender>
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d %-5level [%thread] %logger{0} [%mdc]>: %msg
%replace(%xEx){'\n', ' | '}%nopex%n
</pattern>
</encoder>
</appender>
<!-- default log level for all loggers is INFO by default -->
<root level="${LOG_ROOT_LEVEL:-INFO}">
<appender-ref ref="STDOUT-JSON"/>
Expand Down
Loading