This repository contains the code from the book for Chapter 5, Capturing Application State with Logging Frameworks. See the main book page for the list of all chapter specific repositories.
In this repository, all code is in the main branch. There are seven folders:
| Folder Name | Contents |
|---|---|
| println | Logging without a framework |
| java-util-logging | Java Util Logging examples |
| log4J | Log4j examples |
| logback | Logback examples |
| slf4j-no-library-connfigured | SLF4J example without a library. |
| slf4j-with-simple | SLF4J example with slf4j-simple configured |
| slf4j-conversion | SLF4J example with log4j configured |
Note that many configuration files are supplied. If you want to run with the defaults, please delete these files from src/main/resources of that example.
If you want to use an IDE, import the directory you want as a Maven project so you have the proper logging dependencies.
If you want to use the command line, cd to the directory for that example and run
mvn verify
To run using the system property from the command line example, run the following from the Ch05-Logging/java-util-logging directory:
java -Djava.util.logging.config.file=src/main/resources/logging-warning.properties src/main/java/com/wiley/realworldjava/logging/jul/BasicConfigCommandLine.java
The other examples include the System property in Java code to make it easier to run the examples
Open your .idea/*.iml file and change the inherit-compiler-output value to false
Java Util Logging
- Documentation for Java Util Logging
- For customizing log configuration in Java Util Logging
- For configuring file logging
- For customizing log message format
- Formatter syntax
Log4j
SLF4J
Logback