To set up Spring Boot to display request logs related to Connection refused errors, you can follow these steps:
pom.xml
file:<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.13.2</version>
</dependency>
log4j2.xml
file in your classpath (such as src/main/resources
), with the following content:<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5level %logger{36} - %msg%n" />
</Console>
</Appenders>
<Loggers>
<Root level="INFO">
<AppenderRef ref="Console" />
</Root>
<Logger name="org.springframework.web.client.RestTemplate" level="DEBUG"/>
</Loggers>
</Configuration>
Note that this configuration sets the logging level of org.springframework.web.client.RestTemplate
to DEBUG
, so that it will log connection refused errors.
Restart your Spring Boot application.
When you make a request that results in a connection refused error, you should see a log entry like this:
2021-09-01 15:12:56 [http-nio-8080-exec-1] ERROR o.s.w.c.RestTemplate - I/O error on GET request for "http://localhost:8081/api/customers/1/orders": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)
This log entry shows the time, thread, log level, logger name (org.springframework.web.client.RestTemplate
), and the error message (I/O error on GET request...
).
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-06-04 16:26:04 +0000
Seen: 13 times
Last updated: Jun 04 '23
How can the rejection of the class text_plain from JavaMail API due to a VerifyError be confirmed?
What is the process for generating a dynamic subdomain/URL using vue.js?
How can the style of the loader be modified while the form submission is being processed?
I'm attempting to develop a Javascript-based comments section for my website.
What are some feasible methods to enable MIDI file playback on a web browser?
How can I resolve the issue of being unable to use Fetch to POST an array of Selected Checkboxes?
What is the method to hide the scroll button when reaching the bottom?
What is the process of using a custom nunjucks filter to filter collections in an eleventy template?