hadoop-pig-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benjamin Francisoud <benjamin.francis...@joost.com>
Subject Logging
Date Fri, 25 Jan 2008 16:38:16 GMT

While reading the ProposedRoadMap [1], I found the "Logging" item 
important and easy to fix ;)

I'd like to provide a patch for this but the "Current Situation" chapter 
and what I've seen in the code [2] seems to say that you guys should use 
Using log4j is perfeclty fine (I used it on several project since 2002) 
but making all pig class actually depend on the log4j api would be a bad 
idea :(
Without any extra effort, you can use the "wonderful" commons logging 
abstraction api ;)

Advantages you would get by using commons logging api:
- Making it possible to stwich from log4j, simple log or any logger of 
your choice implementing the common logging api.
- Allow pig users to use the logging system of there choice if, for 
example, the developped there own internal commons logging impl (not my 
case currently but worked for a company where they did just that)
- You wouldn't need to add another layer of indirection in 
PigLogger.java, reducing amount of code and maintenance
- If you decide to change the logging impl the java classes will not 
need to by modify

You simply have to add this line of code to you classes:

private Log log = LogFactory.getLog(Foo.class);

if log4j jar is in the classpath  and it finds a log4j.properties it  
will use log4j at runtime...
It a configuration example, log4j can be configured in many 
non-intrusive ways...

You can read the reason why I'm not using static in this example at 
StaticLog wiki page [3]

I created a page to hold this dicussion result on the wiki [4]

[1] http://wiki.apache.org/pig/ProposedRoadMap
[3] http://wiki.apache.org/jakarta-commons/Logging/StaticLog
[4] http://wiki.apache.org/pig/LoggingPolicy

Benjamin Francisoud

View raw message