• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

confused between log4j and Jakarta Commons Logging

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the difference between them?

I see something confused me as I saw hibernate use Jakarta Commons Logging (JCL)by importing the following classes for logging:

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

At the same time, it defined all logging properties in log4j.properties rather than commons-logging.properties. Is it strange to use JCL with log4j property file???
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Commons Loggin Introduction

Commons Logging - Configuring:

The JCL SPI can be configured to use different logging toolkits (see above). JCL provides only a bridge for writing log messages. It does not (and will not) support any sort of configuration API for the underlying logging system. Configuration of the behavior of the JCL ultimately depends upon the logging toolkit being used. Please consult the documentation for the chosen logging system.
 
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In short Apache Logging is a wrapper for other implementations of logging, and one being log4j. So you still would have to configure log4j, however your code could switch to another logging package in the future without you having to change code. In particular it is probably good for frameworks systems where the framework writer can't be sure of the underlying logging api used by framework users.

In other cases it is probably sufficient to have your own Logger class that fronts log4j and so gaining the flexibility of moving away from log4j should you choose, and yet not adding the apache logging dependency (and learning curve) to your code.
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apaches commons logging is just a abstraction of the logger underneath.

One more similar framework.

Using this framework the underlying logger implementation can be changed.Its finds its usage in third party libraries which plugs and becomes part of some application and in that case it can use the logging framework of the application as this can be configured.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!