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
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Using Python Libraries in Java
  • Designing a Java Connector for Software Integrations
  • How to Convert XLS to XLSX in Java
  • Recurrent Workflows With Cloud Native Dapr Jobs

Trending

  • Beyond Linguistics: Real-Time Domain Event Mapping with WebSocket and Spring Boot
  • How AI Agents Are Transforming Enterprise Automation Architecture
  • How to Format Articles for DZone
  • Microsoft Azure Synapse Analytics: Scaling Hurdles and Limitations
  1. DZone
  2. Coding
  3. Java
  4. Is Standard Java Logging Dead?

Is Standard Java Logging Dead?

Does JUL still have a place in the ecosystem? See how a variety of third-party logging tools stack up against Java's built-in logging power.

By 
Alex Zhitnitsky user avatar
Alex Zhitnitsky
·
Dec. 23, 16 · Analysis
Likes (10)
Comment
Save
Tweet
Share
19.2K Views

Join the DZone community and get the full member experience.

Join For Free

for more like this, visit the takipi blog .

logs

the java log levels showdown: severe fatal error omg panic

capitalized log levels induce high levels of stress. what if, instead of error we’d just use “oops”? on a more serious note, we’ve recently run a huge data crunch over github’s top java projects and the logging statements they use , revealing the log level breakdown of the average java project.

in this post, we’ll explore the resulting data set from another angle, shed some more light on the dataset, and put the focus on the use of standard java.util.logging levels versus more popular frameworks like log4j (+ log4j 2), and logback.

step right in.

meet the players

logging utilities can be roughly divided into two categories: the logging facade and the logging engine.

as far as logging facades go, you pretty much have two choices: slf4j and apache’s commons-logging. in practice, 4 out of 5 java projects choose to go with slf4j . based on data from the top java libraries in 2016 on github . the motivation for using a logging facade is pretty definitive and straightforward, an abstraction on top of your logging engine of choice — allowing you to replace it without changing the actual code and logging statements.

as to the logging engine, the most popular picks are logback, which is an evolved version of log4j , log4j itself, and its new version since the development was passed on to the apache software foundation, log4j2. trailing behind is java’s default logging engine, java.util.logging aka jul.

pointing fingers and calling names

on the “superficial” side of things, each of the logging frameworks has slightly different names for their logging levels.

log levels

in the rare case where slf4j is used with java.util.logging, the following mapping takes place:

finest -> trace
finer -> debug
fine -> debug
info -> info
warning -> warn
severe -> error

another thing to notice here is that logback and java.util.logging have no fatal equivalent. behind those error names, are simple integer values, that help control the logging level in a running application. each library also contains values for off and all, which basically set the logger level to actually transmit everything, or nothing. setting a logger level at warn for instance, would only log warn messages and above – it's practically the default setting for production environments.

by the way, one of the cool things about the tool that we’re building , is that you can get log messages lower than warn in production, even if you’ve set the logger level to warn . check out this video for a quick (25 sec) demonstration .

how does level naming look in practice?

for the data crunch, we focused on the top starred java projects with at least 100 logging statements in either of the methods. examining the data set of projects, here’s what we found:

logging levels by type

only 4.4% of projects exclusively used the java.util.logging naming scheme.

the average non-jul logging project, looked like this (examining 1,313 projects):

the average java log level distribution

to look at the average java.util.logging project, we filtered it down to include only projects who had at least 100 statements from levels that don’t overlap with the non-jul naming scheme (warning and info). this left us with a smaller dataset, so it might not be big enough to make definite conclusions from:

jul logging average

with that said, it looks like in both situations, roughly ⅔ of logging statements are disabled in production , since only warn and above are activated in that case.

fun fact: as an extra datapoint, we also looked at all/off levels. turns out only 8.6% of the projects examined used them both.

how did we reach the data?

the starting point for this research is the github archive , and its datasets on google bigquery. we wanted to focus on qualified java projects, excluding android, sample projects, and simple testers. a natural choice was to look at the most starred projects, taking in the database of the top 400,000 repositories.

we ended up with 15,797 repositories with java source files, 4% of the initial dataset. but it didn’t stop there. looking at the number of logging statements, we decided to only focus on projects with at least 100 different statements. the dataset is available right here .

we believe this to be a fairly representative sample of what we were trying to achieve. for the full walkthrough and the steps we took to reach the data, including the exact sql queries, check out the last part in this post .

final thoughts

this post stresses out that java.util.logging is, well, practically dead. most serious projects choose to go with 3rd party logging frameworks. did you find anything else that we might have missed in the dataset? do you have other interesting questions that can be answered through this or similar data?

feel free to suggest your ideas in the comment section below.

for more like this, visit the takipi blog .

Java (programming language)

Published at DZone with permission of Alex Zhitnitsky, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Using Python Libraries in Java
  • Designing a Java Connector for Software Integrations
  • How to Convert XLS to XLSX in Java
  • Recurrent Workflows With Cloud Native Dapr Jobs

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

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 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!