Skip to content

Commit 8303a52

Browse files
committed
Use Apache Commons Logging
- Remove existing spring-boot-starter-logging - Update to use Springframework's LogAccessor to use commons logging Resolves #2095
1 parent d865408 commit 8303a52

File tree

189 files changed

+741
-996
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

189 files changed

+741
-996
lines changed

document-readers/pdf-reader/src/main/java/org/springframework/ai/reader/pdf/PagePdfDocumentReader.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@
2222
import java.util.List;
2323
import java.util.stream.Collectors;
2424

25+
import org.apache.commons.logging.LogFactory;
2526
import org.apache.pdfbox.pdfparser.PDFParser;
2627
import org.apache.pdfbox.pdmodel.PDDocument;
2728
import org.apache.pdfbox.pdmodel.PDPage;
28-
import org.slf4j.Logger;
29-
import org.slf4j.LoggerFactory;
3029

3130
import org.springframework.ai.document.Document;
3231
import org.springframework.ai.document.DocumentReader;
3332
import org.springframework.ai.reader.pdf.config.PdfDocumentReaderConfig;
3433
import org.springframework.ai.reader.pdf.layout.PDFLayoutTextStripperByArea;
3534
import org.springframework.core.io.DefaultResourceLoader;
3635
import org.springframework.core.io.Resource;
36+
import org.springframework.core.log.LogAccessor;
3737
import org.springframework.util.CollectionUtils;
3838
import org.springframework.util.StringUtils;
3939

@@ -55,9 +55,9 @@ public class PagePdfDocumentReader implements DocumentReader {
5555

5656
private static final String PDF_PAGE_REGION = "pdfPageRegion";
5757

58-
protected final PDDocument document;
58+
private static final LogAccessor logger = new LogAccessor(LogFactory.getLog(PagePdfDocumentReader.class));
5959

60-
private final Logger logger = LoggerFactory.getLogger(getClass());
60+
protected final PDDocument document;
6161

6262
protected String resourceFileName;
6363

@@ -112,7 +112,7 @@ public List<Document> get() {
112112
for (PDPage page : this.document.getDocumentCatalog().getPages()) {
113113
lastPage = page;
114114
if (counter % logFrequency == 0 && counter / logFrequency < 10) {
115-
logger.info("Processing PDF page: {}", (counter + 1));
115+
logger.info("Processing PDF page: " + (counter + 1));
116116
}
117117
counter++;
118118

@@ -154,7 +154,7 @@ public List<Document> get() {
154154
readDocuments.add(toDocument(lastPage, pageTextGroupList.stream().collect(Collectors.joining()),
155155
startPageNumber, pageNumber));
156156
}
157-
logger.info("Processing {} pages", totalPages);
157+
logger.info("Processing " + totalPages + " pages");
158158
return readDocuments;
159159

160160
}

document-readers/pdf-reader/src/main/java/org/springframework/ai/reader/pdf/ParagraphPdfDocumentReader.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323

2424
import org.apache.pdfbox.pdfparser.PDFParser;
2525
import org.apache.pdfbox.pdmodel.PDDocument;
26-
import org.slf4j.Logger;
27-
import org.slf4j.LoggerFactory;
2826

2927
import org.springframework.ai.document.Document;
3028
import org.springframework.ai.document.DocumentReader;
@@ -34,6 +32,7 @@
3432
import org.springframework.ai.reader.pdf.layout.PDFLayoutTextStripperByArea;
3533
import org.springframework.core.io.DefaultResourceLoader;
3634
import org.springframework.core.io.Resource;
35+
import org.springframework.core.log.LogAccessor;
3736
import org.springframework.util.CollectionUtils;
3837
import org.springframework.util.StringUtils;
3938

@@ -62,7 +61,7 @@ public class ParagraphPdfDocumentReader implements DocumentReader {
6261

6362
protected final PDDocument document;
6463

65-
private final Logger logger = LoggerFactory.getLogger(getClass());
64+
private static final LogAccessor logger = new LogAccessor(ParagraphPdfDocumentReader.class);
6665

6766
private final ParagraphManager paragraphTextExtractor;
6867

models/spring-ai-anthropic/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@
7676
<groupId>org.springframework</groupId>
7777
<artifactId>spring-context-support</artifactId>
7878
</dependency>
79-
<dependency>
80-
<groupId>org.springframework.boot</groupId>
81-
<artifactId>spring-boot-starter-logging</artifactId>
82-
</dependency>
8379

8480
<!-- test dependencies -->
8581
<dependency>

models/spring-ai-anthropic/src/main/java/org/springframework/ai/anthropic/AnthropicChatModel.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
import io.micrometer.observation.Observation;
2828
import io.micrometer.observation.ObservationRegistry;
2929
import io.micrometer.observation.contextpropagation.ObservationThreadLocalAccessor;
30-
import org.slf4j.Logger;
31-
import org.slf4j.LoggerFactory;
3230
import reactor.core.publisher.Flux;
3331
import reactor.core.publisher.Mono;
3432

@@ -67,6 +65,7 @@
6765
import org.springframework.ai.model.function.FunctionCallbackResolver;
6866
import org.springframework.ai.model.function.FunctionCallingOptions;
6967
import org.springframework.ai.retry.RetryUtils;
68+
import org.springframework.core.log.LogAccessor;
7069
import org.springframework.http.ResponseEntity;
7170
import org.springframework.retry.support.RetryTemplate;
7271
import org.springframework.util.Assert;
@@ -92,7 +91,7 @@ public class AnthropicChatModel extends AbstractToolCallSupport implements ChatM
9291

9392
public static final Double DEFAULT_TEMPERATURE = 0.8;
9493

95-
private static final Logger logger = LoggerFactory.getLogger(AnthropicChatModel.class);
94+
private static final LogAccessor logger = new LogAccessor(AnthropicChatModel.class);
9695

9796
private static final ChatModelObservationConvention DEFAULT_OBSERVATION_CONVENTION = new DefaultChatModelObservationConvention();
9897

models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/AnthropicChatModelIT.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
2828
import org.junit.jupiter.params.ParameterizedTest;
2929
import org.junit.jupiter.params.provider.ValueSource;
30-
import org.slf4j.Logger;
31-
import org.slf4j.LoggerFactory;
3230
import reactor.core.publisher.Flux;
3331

3432
import org.springframework.ai.anthropic.api.AnthropicApi;
@@ -59,6 +57,7 @@
5957
import org.springframework.core.convert.support.DefaultConversionService;
6058
import org.springframework.core.io.ClassPathResource;
6159
import org.springframework.core.io.Resource;
60+
import org.springframework.core.log.LogAccessor;
6261
import org.springframework.util.MimeType;
6362
import org.springframework.util.MimeTypeUtils;
6463
import org.springframework.util.StringUtils;
@@ -69,7 +68,7 @@
6968
@EnabledIfEnvironmentVariable(named = "ANTHROPIC_API_KEY", matches = ".+")
7069
class AnthropicChatModelIT {
7170

72-
private static final Logger logger = LoggerFactory.getLogger(AnthropicChatModelIT.class);
71+
private static final LogAccessor logger = new LogAccessor(AnthropicChatModelIT.class);
7372

7473
@Autowired
7574
protected ChatModel chatModel;
@@ -284,7 +283,7 @@ void functionCallTest() {
284283

285284
ChatResponse response = this.chatModel.call(new Prompt(messages, promptOptions));
286285

287-
logger.info("Response: {}", response);
286+
logger.info("Response: " + response);
288287

289288
Generation generation = response.getResult();
290289
assertThat(generation).isNotNull();
@@ -324,7 +323,7 @@ void streamFunctionCallTest() {
324323
.map(cr -> cr.getResult().getOutput().getText())
325324
.collect(Collectors.joining());
326325

327-
logger.info("Response: {}", content);
326+
logger.info("Response: " + content);
328327
assertThat(content).contains("30", "10", "15");
329328
}
330329

@@ -350,7 +349,7 @@ void streamFunctionCallUsageTest() {
350349

351350
ChatResponse chatResponse = responseFlux.last().block();
352351

353-
logger.info("Response: {}", chatResponse);
352+
logger.info("Response: " + chatResponse);
354353
Usage usage = chatResponse.getMetadata().getUsage();
355354

356355
assertThat(usage).isNotNull();

models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/EventParsingTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@
2323
import com.fasterxml.jackson.core.type.TypeReference;
2424
import com.fasterxml.jackson.databind.ObjectMapper;
2525
import org.junit.jupiter.api.Test;
26-
import org.slf4j.Logger;
27-
import org.slf4j.LoggerFactory;
2826

2927
import org.springframework.ai.anthropic.api.AnthropicApi.StreamEvent;
3028
import org.springframework.core.io.DefaultResourceLoader;
29+
import org.springframework.core.log.LogAccessor;
3130

3231
import static org.assertj.core.api.Assertions.assertThat;
3332

@@ -37,7 +36,7 @@
3736
*/
3837
public class EventParsingTests {
3938

40-
private static final Logger logger = LoggerFactory.getLogger(EventParsingTests.class);
39+
private static final LogAccessor logger = new LogAccessor(EventParsingTests.class);
4140

4241
@Test
4342
public void readEvents() throws IOException {

models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/api/tool/AnthropicApiLegacyToolIT.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
import org.junit.jupiter.api.Test;
2424
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
25-
import org.slf4j.Logger;
26-
import org.slf4j.LoggerFactory;
2725

2826
import org.springframework.ai.anthropic.api.AnthropicApi;
2927
import org.springframework.ai.anthropic.api.AnthropicApi.AnthropicMessage;
@@ -36,6 +34,7 @@
3634
import org.springframework.ai.anthropic.api.tool.XmlHelper.Tools.ToolDescription;
3735
import org.springframework.ai.anthropic.api.tool.XmlHelper.Tools.ToolDescription.Parameter;
3836
import org.springframework.ai.model.ModelOptionsUtils;
37+
import org.springframework.core.log.LogAccessor;
3938
import org.springframework.http.ResponseEntity;
4039

4140
import static org.assertj.core.api.Assertions.assertThat;
@@ -81,7 +80,7 @@ public class AnthropicApiLegacyToolIT {
8180

8281
public static final ConcurrentHashMap<String, Function> FUNCTIONS = new ConcurrentHashMap<>();
8382

84-
private static final Logger logger = LoggerFactory.getLogger(AnthropicApiLegacyToolIT.class);
83+
private static final LogAccessor logger = new LogAccessor(AnthropicApiLegacyToolIT.class);
8584

8685
AnthropicApi anthropicApi = new AnthropicApi(System.getenv("ANTHROPIC_API_KEY"));
8786

models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/api/tool/AnthropicApiToolIT.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323

2424
import org.junit.jupiter.api.Test;
2525
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
26-
import org.slf4j.Logger;
27-
import org.slf4j.LoggerFactory;
2826

2927
import org.springframework.ai.anthropic.api.AnthropicApi;
3028
import org.springframework.ai.anthropic.api.AnthropicApi.AnthropicMessage;
@@ -35,6 +33,7 @@
3533
import org.springframework.ai.anthropic.api.AnthropicApi.Role;
3634
import org.springframework.ai.anthropic.api.AnthropicApi.Tool;
3735
import org.springframework.ai.model.ModelOptionsUtils;
36+
import org.springframework.core.log.LogAccessor;
3837
import org.springframework.http.ResponseEntity;
3938
import org.springframework.util.CollectionUtils;
4039

@@ -56,7 +55,7 @@ public class AnthropicApiToolIT {
5655

5756
public static final ConcurrentHashMap<String, Function> FUNCTIONS = new ConcurrentHashMap<>();
5857

59-
private static final Logger logger = LoggerFactory.getLogger(AnthropicApiToolIT.class);
58+
private static final LogAccessor logger = new LogAccessor(AnthropicApiToolIT.class);
6059

6160
AnthropicApi anthropicApi = new AnthropicApi(System.getenv("ANTHROPIC_API_KEY"));
6261

models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/client/AnthropicChatClientIT.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
2929
import org.junit.jupiter.params.ParameterizedTest;
3030
import org.junit.jupiter.params.provider.ValueSource;
31-
import org.slf4j.Logger;
32-
import org.slf4j.LoggerFactory;
3331
import reactor.core.publisher.Flux;
3432

3533
import org.springframework.ai.anthropic.AnthropicChatOptions;
@@ -50,6 +48,7 @@
5048
import org.springframework.core.convert.support.DefaultConversionService;
5149
import org.springframework.core.io.ClassPathResource;
5250
import org.springframework.core.io.Resource;
51+
import org.springframework.core.log.LogAccessor;
5352
import org.springframework.test.context.ActiveProfiles;
5453
import org.springframework.util.MimeTypeUtils;
5554

@@ -60,7 +59,7 @@
6059
@ActiveProfiles("logging-test")
6160
class AnthropicChatClientIT {
6261

63-
private static final Logger logger = LoggerFactory.getLogger(AnthropicChatClientIT.class);
62+
private static final LogAccessor logger = new LogAccessor(AnthropicChatClientIT.class);
6463

6564
@Autowired
6665
ChatModel chatModel;
@@ -220,7 +219,7 @@ void functionCallTest() {
220219
.content();
221220
// @formatter:on
222221

223-
logger.info("Response: {}", response);
222+
logger.info("Response: " + response);
224223

225224
assertThat(response).contains("30", "10", "15");
226225
}
@@ -239,7 +238,7 @@ void functionCallWithGeneratedDescription() {
239238
.content();
240239
// @formatter:on
241240

242-
logger.info("Response: {}", response);
241+
logger.info("Response: " + response);
243242

244243
assertThat(response).contains("30", "10", "15");
245244
}
@@ -261,7 +260,7 @@ void defaultFunctionCallTest() {
261260
.content();
262261
// @formatter:on
263262

264-
logger.info("Response: {}", response);
263+
logger.info("Response: " + response);
265264

266265
assertThat(response).contains("30", "10", "15");
267266
}
@@ -282,7 +281,7 @@ void streamFunctionCallTest() {
282281
// @formatter:on
283282

284283
String content = response.collectList().block().stream().collect(Collectors.joining());
285-
logger.info("Response: {}", content);
284+
logger.info("Response: " + content);
286285

287286
assertThat(content).contains("30", "10", "15");
288287
}
@@ -344,7 +343,7 @@ void streamingMultiModality() throws IOException {
344343

345344
String content = response.collectList().block().stream().collect(Collectors.joining());
346345

347-
logger.info("Response: {}", content);
346+
logger.info("Response: " + content);
348347
assertThat(content).contains("bananas", "apple");
349348
assertThat(content).containsAnyOf("bowl", "basket");
350349
}

0 commit comments

Comments
 (0)