|
| 1 | +# Java Logger Intro [![Gayanuka Bulegoda][grb-shield]][grb-url] |
| 2 | + |
| 3 | +This project demonstrates Java's built-in logger capabilities through a simple Spring Boot REST controller. It serves as a practical example for configuring and using various logging levels within a Spring Boot application. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The Java Logger Intro Sample project is designed to help developers understand how to implement and configure Java’s inbuilt logging framework within a Spring Boot environment. It illustrates the usage of multiple logging levels to provide insights into system operations, warnings, errors, and detailed debugging information. |
| 8 | + |
| 9 | +## Features |
| 10 | +- **Spring Boot REST Controller**: Provides an endpoint to trigger logging. |
| 11 | +- **Multiple Logging Levels**: Demonstrates INFO, WARN, ERROR, FATAL, DEBUG, and TRACE levels. |
| 12 | +- **Configurable Logging**: Easy-to-customize logging settings using `application.properties`. |
| 13 | + |
| 14 | +## Prerequisites |
| 15 | +- Java JDK 17 or later |
| 16 | +- Maven build tool |
| 17 | +- Basic understanding of Spring Boot |
| 18 | + |
| 19 | +## Installation |
| 20 | + |
| 21 | +1. **Clone the repository:** |
| 22 | + |
| 23 | + ```bash |
| 24 | + https://github.com/GRB-Sample-Workspace/Java-Logger-Intro.git |
| 25 | + ``` |
| 26 | + |
| 27 | +2. **Navigate to the project directory:** |
| 28 | + |
| 29 | + ```bash |
| 30 | + cd Java-Logger-Intro |
| 31 | + ``` |
| 32 | + |
| 33 | +3. **Build and run the application:** |
| 34 | + |
| 35 | + |
| 36 | + ```bash |
| 37 | + mvn spring-boot:run |
| 38 | + ``` |
| 39 | + |
| 40 | +## Usage |
| 41 | + |
| 42 | +Once the application is running, you can access the sample REST endpoint at: |
| 43 | + |
| 44 | +```bash |
| 45 | +http://localhost:8085/log |
| 46 | +``` |
| 47 | + |
| 48 | +Triggering the endpoint will log messages using the different logging levels as configured. |
| 49 | + |
| 50 | +## Configuration |
| 51 | + |
| 52 | +The logging behavior is controlled through the `application.properties` file. For example, you can adjust the root logging level: |
| 53 | + |
| 54 | +```properties |
| 55 | +logging.level.root=INFO |
| 56 | +logging.level.com.example=DEBUG |
| 57 | +``` |
| 58 | + |
| 59 | +Modify these settings to increase or decrease log verbosity as needed. |
| 60 | + |
| 61 | +## Logging Levels |
| 62 | + |
| 63 | +- **INFO**: Logs general system information. |
| 64 | +- **WARN**: Logs warnings about non-critical issues. |
| 65 | +- **ERROR**: Logs critical errors. |
| 66 | +- **FATAL**: Logs fatal errors that may cause the system to crash. |
| 67 | +- **DEBUG**: Logs detailed information for debugging purposes. |
| 68 | +- **TRACE**: Logs very detailed, step-by-step trace information. |
| 69 | + |
| 70 | +## Contributing |
| 71 | + |
| 72 | +Contributions are welcome! Please fork the repository and submit a pull request with your improvements. |
| 73 | + |
| 74 | +## License |
| 75 | + |
| 76 | +This project is distributed under the [MIT License](LICENSE). |
| 77 | + |
| 78 | +## Contact |
| 79 | + |
| 80 | +Gayanuka Bulegoda |
| 81 | +[Website](https://grbulegoda.me/) • [GitHub](https://github.com/gayanukabulegoda) |
| 82 | + |
| 83 | +--- |
| 84 | + |
| 85 | +<div align="center"> |
| 86 | + <p> |
| 87 | + © 2025 Gayanuka Bulegoda |
| 88 | + </p> |
| 89 | +</div> |
| 90 | + |
| 91 | +--- |
| 92 | + |
| 93 | +[grb-shield]: https://img.shields.io/badge/GRB-000000?style=for-the-badge&logo=github&logoColor=white |
| 94 | +[grb-url]: https://grbulegoda.me/ |
0 commit comments