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
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
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
  1. DZone
  2. Coding
  3. Java
  4. Shouldn’t we Standardize a Java Logging API?

Shouldn’t we Standardize a Java Logging API?

Antonio Goncalves user avatar by
Antonio Goncalves
·
Sep. 07, 12 · Interview
Like (0)
Save
Tweet
Share
15.79K Views

Join the DZone community and get the full member experience.

Join For Free

i need you for logging api spec lead if you are interested in java ee development and the roadmap, you might have read recently that the cloud feature in java ee 7 has been delayed . as i’ve already expressed in the java ee 7 expert group mailing list , i’m happy about this news because i feel standardizing cloud in ee 7 was way too early. but i’m also sad. sad because we’ve spent a lot of time discussing cloud, paas, multi-tenancy… and not concentrating on other topics. and one topic that i have in mind is logging! shouldn’t we standardize a logging api ?

a few months ago i was struggling (again) with logging configuration in jboss 7.x. i was so depressed that i wrote to the java ee 7 expert group : logs. should we finally do something ? (you should read it, there are valuable opinions expressed by the members). as a developer i’ve used all the possible logging java frameworks for the last 12 years and i still struggle with logging in 2012. how many logging frameworks do we have ? look at the list :

  • jul : the good old java.util.logging api that is included in our jdk. bad luck, it is there and nobody uses it
  • log4j : widely used, log4j hasn’t really been updated lately ( update : the team is working on a 2.0 version )
  • commons logging : how many more apache logging frameworks do you want ?
  • slf4j : if you are not sure which logging api to use, well, use an abstraction (hum, abstraction, we love abstraction)
  • logback : the successor of log4j (successor ? really ?)
  • tinylog : because all these frameworks are too big, we need to use a tiny one
  • and many many many more java logging frameworks

i’m not a log expert and i’m sure all these frameworks exist for good reasons (i’m trying to be politically correct here), but for god sake, we just need to write logs. i don’t want to do a benchmark of all the logging apis to make up my mind. i don’t want to have to relearn a new logging framework each time a new version of my application server is out (yes, jboss 7 uses its own jboss logging api ). to be honest, instead of all saying “using system.out.println is bad” we should have encouraged it and let java se redirect the messages to files (using external configuration). this way our code would be full of system.out.println("message") or system.out.println(warning, "message") and we would have avoided all the logging frameworks. anyway, this is the situation we’re in.

let’s standardize a logging api

standardizing too soon is bad… but we’ve been doing logs for more than a decade now. we have a big expertise in logging, we could even take some ideas of other languages. so it’s time to standardize logging . let’s not do the same mistake as jul and only standardize an api. then, we could let all the known frameworks to implement it and fight about better performances or functionalities. today, logging portability is a nightmare, enough. with a standard api we could also have some tooling and descent log viewers coming on board.

integrate this logging api in java ee (and other specs)

if all the java ee specs (ejb, jpa, jax-rs, cdi…) use this standard api and impose it to the implementations, we could then easily change the level of logs in a standard way on our applications by using a simple package naming convetion:

javax.ejb.level = debug         // ejb spec
javax.persistence.level = debug // jpa spec
org.weld.level = debug          // cdi implementation (weld)
my.app.level = debug            // my application

and who knows, when modularization arrives we could get rid of java.util.logging and have a new javax.logging module in java se (and choose the implementation).

think to the future

if we had a logging api 1.0 specification , then, when multi-tenancy comes along, we could have a logging api 1.1 which handles it (wouldn’t it be nice to have multi-tenant logs with no effort ?). another idea would be to play with staging. jsf 2.0 introduced staging and it might be spread all over java ee. if that’s the case, we could simply use default logging : debug for development, warning for production… that would simplify configuration.

do you feel like being a spec lead ?

no, it’s not because i write this blog post that i want to be a spec lead. i’m not the right person, i’ve never implemented a logging framework, i’m just a user of theses apis. so if you feel you know the topic well, if you know people who could help you by being part of your expert group (if you want, i could even join this expert group), then do it. entering the jcp is not a piece of cake, you need to do a bit of administration to have your jsr approved, but it’s doable.  you would need a bit of time, but it’s doable. even if you start now i’m not sure there will be enough time to take the java ee 7 train, but the jcp has some examples of quick jsrs.

so, who wants to be a logging api spec lead ? do you think it’s a good idea to standardize a logging api ?




Java (programming language) API Java EE Framework

Published at DZone with permission of Antonio Goncalves, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Agile Transformation With ChatGPT or McBoston?
  • Why It Is Important To Have an Ownership as a DevOps Engineer
  • What Is Policy-as-Code? An Introduction to Open Policy Agent
  • What Was the Question Again, ChatGPT?

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: