DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Java 2021: What Frameworks and Trends for This New Year?
  • A Spring Boot App With Half the Startup Time
  • Improving Java Application Reliability with Dynatrace AI Engine
  • A Systematic Approach for Java Software Upgrades

Trending

  • Fix the Target, Precompute Once: A Backend-Free Word-Ladder Solver With a BFS Distance Field
  • Part 3: End-to-End Tracing and Observability Across Goose, agentgateway, and Quarkus
  • AI Agents and Frontier Models: Insights From The Neuron
  • After the AI Commit: What Eight Retrospectives Taught Me About Working With Coding Agents

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Coding
  3. Frameworks
  4. Java Logging Frameworks and Tools

Java Logging Frameworks and Tools

In this post, we take a look at some of the most common and well-known logging frameworks available in Java to see what you should consider for your projects.

By 
Swathi Prasad
·
Updated Oct. 10, 17 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
46.8K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

Logging information in your application is critical to the understanding of the runtime behavior of any application, especially in cases when you encounter unexpected scenarios, errors, or just for tracking certain activities.

As more and more companies move to the cloud, log analysis and log management tools and services are becoming more critical. Some tools, such as Loggly, Logstash, Graylog, etc., help you to analyze and monitor logs.

Overall, logging is certainly a fundamental practice that provides significant benefits during the lifetime of an application.

Let’s look at some Java logging frameworks and tools.

Apache Log4j 2

Apache Log4j 2 is an upgrade to Log4j that provides many of the improvements available in Logback while fixing some inherent problems in Logback’s architecture. It provides asynchronous logging, which significantly improves performance, especially in multi-threaded applications.

We can include the Maven dependency as follows:

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.9.1</version>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.9.1</version>
</dependency>


Logback

Logback is an improved version of log4j. It is conceptually like log4j, as both projects were founded by the same developer. If you are already familiar with log4j, you can pick up Logback quickly.

Visit the official site to know about all of its benefits.

Include the Maven dependency as follows:

<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>1.2.3</version>
</dependency>


tinylog

tinylog is a logging framework for Java and Android. The logger is static, so it is not necessary to create an instance of the logger before logging.

We can include the Maven dependency as follows:

<dependency>
    <groupId>org.tinylog</groupId>
    <artifactId>tinylog</artifactId>
    <version>1.2</version>
</dependency>


Logbook

Logbook is a Java library to enable complete request and response logging for various client and server-side technologies. It provides support for Servlet containers, Apache’s HTTP client, and other frameworks. It also has auto-configuration for Spring Boot.

We can selectively add the dependencies to the project:

<dependency>
    <groupId>org.zalando</groupId>
    <artifactId>logbook-core</artifactId>
    <version>1.4.0</version>
</dependency>
<dependency>
    <groupId>org.zalando</groupId>
    <artifactId>logbook-servlet</artifactId>
    <version>1.4.0</version>
</dependency>
<dependency>
    <groupId>org.zalando</groupId>
    <artifactId>logbook-httpclient</artifactId>
    <version>1.4.0</version>
</dependency>
<dependency>
    <groupId>org.zalando</groupId>
    <artifactId>logbook-spring-boot-starter</artifactId>
    <version>1.4.0</version>
</dependency>


Conclusion

Logging is very important in application development due to the highly useful and actionable insights it brings during the runtime of an application. Choose the framework as per your project needs and log wisely!

Framework Java (programming language) application

Published at DZone with permission of Swathi Prasad. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Java 2021: What Frameworks and Trends for This New Year?
  • A Spring Boot App With Half the Startup Time
  • Improving Java Application Reliability with Dynatrace AI Engine
  • A Systematic Approach for Java Software Upgrades

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook