On 17 Jul 2013, at 10:23, Stuart Rossiter <[email protected]> wrote:

> BTW (general question to the mailing list): this code suggests that the 
> getLogger(Class clazz) form sets the logger name using the source file name 
> (e.g., SLF4JConsoleTest.java here, cf. SLF4JConsoleTest). I've always used 
> the getLogger(String name) form, passing 
> SLF4JConsoleTest.class.getCanonicalName(), or getSimpleName() if I don't want 
> the full name. (It might even be that I changed to that because of this ugly 
> .java suffix, though I can't explicitly remember that.)
> 
> Is there a reason for that? If it's to link to the file producing it (rather 
> than the class), that doesn't seem very useful without a path.

Stuart, maybe you picked up this habit from java.util.logging which only allows 
string names to be passed when creating a logger.

I personally favour the "LoggerFactory.getLogger(MyClass.class)" form for the 
following reasons:
 1) Typo avoidance - if I misspell the class name, then the IDE and compiler 
will complain
 2) Tooling support - Find Usages, Rename Class refactorings will work without 
having to enable 'seach in strings'

There is no .java stuffix, just the .class suffix, and it's not so ugly, in 
fact the IDE makes it a pretty colour!  :-)

David
_______________________________________________
Logback-user mailing list
[email protected]
http://mailman.qos.ch/mailman/listinfo/logback-user

Reply via email to