Over a million developers have joined DZone.

Logger Tinylog 0.8 Supports Application Servers

DZone's Guide to

Logger Tinylog 0.8 Supports Application Servers

· DevOps Zone ·
Free Resource

Read why times series is the fastest growing database category.

tinylog, an open source logger for Java, has been released in version 0.8. The second to last beta version of tinylog uses class loaders in a different way to supports also application servers such as Glassfish. tinylog is a lightweight alternative to the "de-facto standard Log4j". The aim of the project is to simplify logging in Java. There is only one static logger in tinylog. So the usual and error-prone creation of a logger instance for each class by "Logger.getLogger(MyClass.class)" isn’t necessary anymore.

In tinylog 0.8, the configuration API has been separated from the logging API. Now, the logger can be configured by a fluent interface in the program itself. Of course, it is still possible to configure the logger by environment variables or a properties file. New is that tinylog can observe properties files. This means that changes in the property file will be detected and automically reloaded. Thus, tinylog can be reconfigured at runtime.

Like all loggers, also tinylog uses the stack trace to get runtime information, such as the method or the line in which the log entry has been generated. But due to the special architecture, tinylog knows always the position of the required stack trace element (the depth).  So tinylog can load only the required stack trace element and mustn’t load the full stack trace like other loggers. This is much faster. The loading of the stack trace is usually the "most expensive" operation of a logger and therefore crucial for the performance.

All tests are completely rewritten on the basis of JUnit 4.11 and Hamcrest 1.3. There are now 155 tests, which covers 94 % of the source code of tinylog according to the code coverage tool EclEmma. This shall ensure the stability of tinylog and especially prevent regressions. The new test code is 1.5 times larger than the actual source code of tinylog.

Now, tinylog isn't only as JAR available, but also as Maven artifact and as OSGi bundle. The OSGi bundle can be used as a plug-in in Eclipse RCP applications.

For the last beta version 0.9, the support of multiple logging writers is planned. This will allow for example to write simultaneously log entries to the console and in a log file. But first, Log4j Facade will be released. Log4j Facade is already in the advanced development phase and is a Log4j compatible logging API for tinylog. Log4j Facade simplifies switching from Log4j to tinylog, because it ensures that existing source code and libraries which are using Log4j for logging work with tinylog.

The JAR file of the tinylog 0.8 has a size of only 38 KB. You can download it from www.tinylog.org/download.

Learn how to get 20x more performance than Elastic by moving to a Time Series database.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}