# springboot3-logbook **Repository Path**: acaiblog/springboot3-logbook ## Basic Information - **Project Name**: springboot3-logbook - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-04-15 - **Last Updated**: 2025-04-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Logbook Custom HTTP Log Formatter A Spring Boot application showcasing how to customize HTTP request and response logging formats using Logbook. ## Key Features - **Customizable HTTP Logging**: Customize the format of HTTP requests and responses logs. - **Spring Boot Actuator Integration**: Provides health checks and metrics collection for the application. - **Logbook Integration**: Detailed logging of HTTP interactions with custom formatting. ## Build and Run Ensure you have Maven and Java 17 installed. ### Get the Code ```bash git clone https://github.com/yourusername/logbook.git cd logbook ``` ### Compile and Run ```bash mvn clean install mvn spring-boot:run ``` Or run it directly from the compiled jar: ```bash java -jar target/logbook-0.0.1-SNAPSHOT.jar ``` ## Directory Structure ``` springboot3-logbook/ ├─ .idea/ ├─ .mvn/ │ └─ wrapper/ ├─ src/ │ ├─ main/ │ │ ├─ java/ │ │ │ └─ com/ │ │ │ └─ example/ │ │ │ └─ logbook/ │ │ │ ├─ config/ │ │ │ ├─ controller/ │ │ │ └─ utils/ │ │ └─ resources/ │ │ ├─ static/ │ │ └─ templates/ │ └─ test/ │ └─ java/ │ └─ com/ │ └─ example/ │ └─ logbook/ └─ target/ ``` - `src/main/java`: Contains all the main source code. - `src/main/resources`: Resources such as configuration files, static assets, etc. - `src/test/java`: Test cases. ## Example Requests Below are examples of how the customized HTTP logging appears in the logs: ### Request and Response Logging Example **Request:** ```plaintext 2025-04-15 10:22:52 TRACE - DefaultHttpLogWriter.java:25 write Request: Method=GET, URI=http://localhost:8080/ ``` **Response:** ```plaintext 2025-04-15 10:22:52 TRACE - DefaultHttpLogWriter.java:30 write Response: Status=200, Body=Hello, World! ``` This shows a simple GET request to the root URL (`/`) and the corresponding response with status code `200` and body `Hello, World!`. ## Dependency Management Please refer to [pom.xml](pom.xml) for the complete list of dependencies. This project is based on Spring Boot 3.3.10 and includes key dependencies like: - Spring Boot Starter Web - Spring Boot Starter Actuator - Logbook Spring Boot Starter (version 3.11.0) ## License This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. ## Contributing Contributions are welcome! Please fork the repository and submit a pull request. For major changes, please open an issue first to discuss what you would like to change.