[ 
https://issues.apache.org/jira/browse/KAFKA-6298?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16275306#comment-16275306
 ] 

Jason Gustafson commented on KAFKA-6298:
----------------------------------------

Unfortunate. The line numbers can be helpful in matching the version in use. A 
possible workaround would be to use the {{LocationAwareLogger.log}} api if the 
logger implements it since it allows us to override the class name of the 
caller. For example, inside {{LogContext.KafkaLogger}}:
{code}
        @Override
        public void debug(String message) {
            if (logger.isDebugEnabled()) {
                logger.log(null, KafkaLogger.class.getName(), 
LocationAwareLogger.DEBUG_INT, message, null, null);
            }
        }
{code}
I tested this locally and it solves the problem (at least for Log4J). Would be 
a pity to abandon {{LogContext}} since it cleaned up a lot of code, but there 
might be friendlier patterns for the logging system to do what we want.

> Line numbers on log messages are incorrect
> ------------------------------------------
>
>                 Key: KAFKA-6298
>                 URL: https://issues.apache.org/jira/browse/KAFKA-6298
>             Project: Kafka
>          Issue Type: Bug
>            Reporter: Colin P. McCabe
>
> The line numbers on log messages are all incorrect now.
> For example, AdminClient should have this log message on line 394:
> {code}
> 394 log.debug("Kafka admin client initialized")
> {code}
> But instead, it shows up as being on line 177:
> {code}
>     [2017-12-01 15:42:18,710] DEBUG [AdminClient clientId=adminclient-1] 
> Kafka admin client initialized 
> (org.apache.kafka.clients.admin.KafkaAdminClient:177)
> {code}
> The line numbers appear to be coming from {{LogContext.java}}:
> {code}
> 174        @Override
> 175        public void debug(String message) {
> 176            if (logger.isDebugEnabled())
> 177                logger.debug(logPrefix + message);
> 178        }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to