Simple Logger is a lightweight, extensible Java logging framework designed to provide flexible and configurable logging capabilities for Java applications. It supports multiple output destinations and customizable log formats.
- Log Levels: Supports DEBUG, INFO, WARN, ERROR
- Formatters: Includes PlainTextFormatter and JsonFormatter
- Outputs: Logs can be output to console and/or files
- Configuration: Easily configurable using a builder pattern
- Thread-Safe: File operations are thread-safe
- Java 8+ Compatibility: Designed to work with Java 8 and higher
- Java 8 or higher
- Maven for building the project
- Clone the repository:
git clone <repository-url>
- Navigate to the project directory:
cd simple-logger
- Build the project using Maven:
mvn clean install
Here's a simple example of how to use Simple Logger:
import com.logging.Logger;
import com.logging.core.LogLevel;
public class Main {
public static void main(String[] args) {
Logger logger = Logger.getLogger("MyLogger");
logger.info("This is an info message");
logger.error("This is an error message");
}
}
You can configure the logger with different formatters and outputs:
import com.logging.Logger;
import com.logging.core.LogConfig;
import com.logging.core.LogLevel;
import com.logging.formatter.JsonFormatter;
import com.logging.output.FileOutput;
public class Main {
public static void main(String[] args) {
LogConfig config = LogConfig.builder()
.setMinimumLevel(LogLevel.DEBUG)
.setFormatter(new JsonFormatter())
.addOutput(new FileOutput("logs/application.log"))
.build();
Logger logger = Logger.getLogger("ConfiguredLogger", config);
logger.debug("This is a debug message");
}
}
Contributions are welcome! Please fork the repository and submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.