tinylog
tinylog is a lightweight open-source logging framework for Java and Android, optimized for ease of use.
Ease of use
The logger of tinylog is static, so it isn't necessary to create an instance of the logger before logging. By default all log entries of the level info or higher are written to the console.
import org.pmw.tinylog.Logger;
public class Application {
public static void main(String[] args) {
Logger.info("Hello World!");
}
}
You will see something like this in your console:
2024-11-21 07:20:51 [main] Application.main() INFO: Hello World!
Configurable
tinylog can be configured by system properties, properties files and a fluent Java API.
How to write log entries of the level warning or higher to a file:
tinylog.writer = file tinylog.writer.filename = log.txt tinylog.level = warning
Or in Java:
Configurator.defaultConfig()
.writer(new FileWriter("log.txt"))
.level(Level.WARNING)
.activate();
You can find the full list of properties and statements in the documentation.
Fast
tinylog is very small, so it's simple to optimize the logging performance e.g. by precompiled patterns. The result can be seen in the benchmark. There tinylog was up to six times faster than the popular log4j!
Scalable
tinylog is thread-safe. So the logger can be used in multi-threaded programs without the need of locking. All log entries are always created and written as a whole. Running on machines with multiple cores, tinylog benefits from the additional cores.
Small
As the name "tinylog" implies, tinylog is very small. The tinylog JAR has a size of only 105KB!