ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <>
Subject Re: [Vote] Logging
Date Thu, 10 May 2001 02:40:54 GMT
At 01:26  10/5/01 -0000, Magesh Umasankar wrote:
>To perform a simple log operation in Log4J:
>   Category  cat = Category.getInstance("");
>   cat.setPriority(Priority.DEBUG);
>   cat.debug("Debug Message"); 
>To perform a simple log operation in LogKit:
>   Category cat = new Category("");
>   cat.setPriority(Priority.DEBUG);
>   Logger logger = new Logger(cat);
>   logger.debug("Debug Message");

Actually if you were to use that model they would be exactly the same ;)
    Logger logger = LogKit.getLoggerFor("");
    logger.debug("Debug Message");

>Doesn't seem a lot different at least in the simplest of cases.  

True but if you looked at a simple one target "echo" buildfile between ant
and make ... make would look far simpler ;)

>Please explain (probably more complex scenarios) where the simplicity of
LogKit wins over Log4J.

Essentially UI of Logger and use cases designed for. 

UI - Logger interface is less complex - it doesn't try to do
internationalisation. object rendering/logging, or unsafe things like
giving access to hierarchy *shudder*.

LogKit was designed for use in an IOC environment - ie if you have access
to logger about "" you cannot access "com" in any manner - however
you can get access to further sub-categories. ie Logger sub =
logger.getChildLogger( "foo" ); would get "" This means you can
never break out of your shell so to speak.

Also most classes who use logger get it provided by their container via
Avalons Loggable interface. Most of these classes extend AbstractLoggable
as a convenience use. Thus a common use case would look like

MyClass extends AbstractLoggable 
  void method1()
    getLogger().debug( "MyMessage" );
    MySubComponent msc = new MySubComponent();
    setupLogger( msc, "msc" );

In this case it is the container of MyClass that decides the logger
category to provide the object lets say for example it is "";
However myclass can also provide loggers to sub components and does so in
this case creating "".

Thus to do logging in any of these components it is as simple as 

getLogger().debug( "MyMessage" );

and it will route to correct category. There is also no problem in passing
around loggers as they are all "safely" locked away and you can't reverse
traverse back up. This becomes especially important when we start dealing
wit cases of container tasks (not important for hierarchial builds though -
more on this later).

LogKit is slightly easier to setup but this is irrelevent with respect to
Ant because we will do it once.

Theres a few other nits but the above is the basics.



| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |

View raw message