[prev in list] [next in list] [prev in thread] [next in thread] 

List:       slf4j-dev
Subject:    [slf4j-dev] [JIRA] (SLF4J-154) Copy & paste of LoggerFactory.getLogger
From:       "QOS.CH (JIRA)" <noreply-jira () qos ! ch>
Date:       2018-04-23 6:52:00
Message-ID: JIRA.12633.1260432811000.1818.1524466320309 () Atlassian ! JIRA
[Download RAW message or body]


    [ https://jira.qos.ch/browse/SLF4J-154?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=19175#comment-19175 \
] 

Joachim Durchholz commented on SLF4J-154:
-----------------------------------------

Oh. It just occurred to me that there should not be much code bloat from \
LoggerFactory.getClassLogger() if the code to extract the class name is already in \
place for detectLoggerNameMismatch.

> Copy & paste of LoggerFactory.getLogger
> ---------------------------------------
> 
> Key: SLF4J-154
> URL: https://jira.qos.ch/browse/SLF4J-154
> Project: SLF4J
> Issue Type: Bug
> Components: Core API
> Environment: Operating System: All
> Platform: All
> Reporter: Thomas Mueller
> Assignee: SLF4J developers list
> Attachments: clipboard.png
> 
> 
> This is a feature request.
> Currently, when I create a new logger in a class, I copy & paste the following line \
> from another class: private static Logger log = \
> LoggerFactory.getLogger(AcmeImpl.class); Sometimes I forget to change the class \
> name. SLF4J could help me here. I suggest to add a new method, so the class name is \
> not required, so that I can copy & paste the line without having to remember that I \
> have to change the class name. Also, it's a bit shorter: private static Logger log \
> = LoggerFactory.getCallerClassLogger(); This is copy & paste friendly. The \
> implementation is tricky, but trivial once you understand it: \
> getCallerClassLogger() { return getLogger(new \
> Error().getStackTrace()[1].getClassName()); }
> There is a project that tries to solve the copy & paste problem: \
> http://code.google.com/p/morbok/



--
This message was sent by Atlassian JIRA
(v7.3.1#73012)
_______________________________________________
slf4j-dev mailing list
slf4j-dev@qos.ch
http://mailman.qos.ch/mailman/listinfo/slf4j-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic