Skip to content

Commit e60d63f

Browse files
committed
security: modernize Java 8 logging stack
1 parent 0506d29 commit e60d63f

8 files changed

Lines changed: 31 additions & 25 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,13 @@ Sample implementation library:
180180
</project>
181181
```
182182

183+
### Logging compatibility
184+
185+
The Spring Boot integration does not transitively select a logging implementation. Applications should provide the
186+
SLF4J provider they use, such as Logback or Log4j 2. Capa's Java 8 Logback adapters compile against SLF4J 2.0.17 and
187+
Logback 1.3.16; their logging dependencies remain optional so Spring Boot applications can keep their own managed
188+
logging stack.
189+
183190
### Running the examples
184191

185192
Try the following examples to learn more about Capa's Java SDK:

README_ZH.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ Sample implementation library:
148148
</project>
149149
```
150150

151+
### 日志兼容性
152+
153+
Spring Boot 集成模块不会再传递引入具体日志实现。应用需要自行提供所使用的 SLF4J provider,例如 Logback 或
154+
Log4j 2。Capa 的 Java 8 Logback 适配模块使用 SLF4J 2.0.17 和 Logback 1.3.16 编译;日志依赖保持可选,
155+
因此 Spring Boot 应用可以继续使用自身管理的日志技术栈。
156+
151157
### Running the examples
152158

153159
Try the following examples to learn more about Capa's Java SDK:

examples/pom.xml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232

3333
<properties>
3434
<log4j.version>2.25.4</log4j.version>
35-
<logback.version>1.2.13</logback.version>
35+
<logback.version>1.3.16</logback.version>
36+
<slf4j.version>2.0.17</slf4j.version>
3637
</properties>
3738

3839
<dependencies>
@@ -72,12 +73,6 @@
7273
<version>${logback.version}</version>
7374
</dependency>
7475

75-
<!--lombok-->
76-
<dependency>
77-
<groupId>org.projectlombok</groupId>
78-
<artifactId>lombok</artifactId>
79-
<version>1.18.2</version>
80-
</dependency>
8176
</dependencies>
8277

8378
<build>

examples/src/main/java/group/rxcloud/capa/examples/log/DemoLog.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
*/
1717
package group.rxcloud.capa.examples.log;
1818

19-
import lombok.extern.slf4j.Slf4j;
19+
import org.slf4j.Logger;
20+
import org.slf4j.LoggerFactory;
2021

2122
/**
2223
* An application cannot use log4j and logback configuration to print logs at the same time.
@@ -26,13 +27,14 @@
2627
* 1. Resources cannot contain log4j2.xml and logback.xml files at the same time,
2728
* 2. log4j-slf4j-impl and logback-classic cannot exist at the same time.
2829
*/
29-
@Slf4j
3030
public class DemoLog {
3131

32+
private static final Logger LOG = LoggerFactory.getLogger(DemoLog.class);
33+
3234
public static void main(String[] args) {
3335
try {
34-
log.info("test");
35-
}catch (Exception e){
36+
LOG.info("test");
37+
} catch (Exception e) {
3638
System.out.println();
3739
}
3840

sdk-component/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
<okhttp.version>4.12.0</okhttp.version>
3535
<kotlin-stdlib.version>1.8.21</kotlin-stdlib.version>
3636
<log4j.version>2.25.4</log4j.version>
37-
<logback.version>1.2.13</logback.version>
37+
<logback.version>1.3.16</logback.version>
38+
<slf4j.version>2.0.17</slf4j.version>
3839
</properties>
3940

4041
<dependencies>

sdk-spi-demo/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232

3333
<properties>
3434
<log4j.version>2.25.4</log4j.version>
35-
<logback.version>1.2.13</logback.version>
35+
<logback.version>1.3.16</logback.version>
36+
<slf4j.version>2.0.17</slf4j.version>
3637
</properties>
3738

3839
<dependencies>

sdk-spi/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232

3333
<properties>
3434
<log4j.version>2.25.4</log4j.version>
35-
<logback.version>1.2.13</logback.version>
35+
<logback.version>1.3.16</logback.version>
36+
<slf4j.version>2.0.17</slf4j.version>
3637
</properties>
3738

3839
<dependencies>

sdk-springboot/pom.xml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
<properties>
3333
<jackson.version>2.18.8</jackson.version>
34-
<logback.version>1.2.13</logback.version>
3534
<okhttp.version>4.12.0</okhttp.version>
3635
<spring-framework.version>5.3.39</spring-framework.version>
3736
<springboot.version>2.7.18</springboot.version>
@@ -61,16 +60,6 @@
6160
<type>pom</type>
6261
<scope>import</scope>
6362
</dependency>
64-
<dependency>
65-
<groupId>ch.qos.logback</groupId>
66-
<artifactId>logback-classic</artifactId>
67-
<version>${logback.version}</version>
68-
</dependency>
69-
<dependency>
70-
<groupId>ch.qos.logback</groupId>
71-
<artifactId>logback-core</artifactId>
72-
<version>${logback.version}</version>
73-
</dependency>
7463
<dependency>
7564
<groupId>com.squareup.okhttp3</groupId>
7665
<artifactId>okhttp</artifactId>
@@ -90,6 +79,10 @@
9079
<groupId>org.springframework.boot</groupId>
9180
<artifactId>spring-boot-starter</artifactId>
9281
<exclusions>
82+
<exclusion>
83+
<groupId>org.springframework.boot</groupId>
84+
<artifactId>spring-boot-starter-logging</artifactId>
85+
</exclusion>
9386
<exclusion>
9487
<groupId>org.yaml</groupId>
9588
<artifactId>snakeyaml</artifactId>

0 commit comments

Comments
 (0)