> Crazy.  I had a similar thought (just using enums)
Thats funny, when I was thinking about this, I originally started
thinking with enums.

> So I can see some appeal to the idea.  I guess if we used old school
> enums as you propose we could make it work.  We just need some nice
> way to create the "sub categories".  Maybe we could tuck the creation
> of the non static final (the dynamically created) LogCategories away
> as in..
>
>   // Standard setup part
>   private static final Logger log = Logger.getInstance
> (LogCategory.OPENEJB_DEPLOY, Foo.class);
>
>   // Now later i need to do something app specific
>   Logger appLog = log.getLogger("mySuperApp");
>
>   -- - - -- - - - - - -
>
> Under the covers it might just be something like:
>
>   return Logger.getInstance(this.logCategory.createChild
> ("mySuperApp", this.packageName);

Very cool, I was thinking how to do it, the above seems a very elegant
solution. I was just thinking about the following where we pass in a
string.

 Logger appLog = log.getLogger("mySuperApp");

Is it possible to pass in some sort of custom object, like a ModuleId
object or something.
So, the above could look like

 Logger appLog = log.getLogger(ModuleId.get("mySuperApp"));

And ModuleId could be something like

public final class ModuleId {
    private String name;
    private ModuleId(String name){ this.name = name;}
    public ModuleId get(String name){return new ModuleId(name);}
}

I know that the above is probably slightly more convoluted than using
a String, but I was thinking that a custom object would keep the
Logging API "strict,tight and unambiguous".
-- 
Karan Singh Malhi

Reply via email to