You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "Viktor Somogyi (JIRA)" <ji...@apache.org> on 2017/06/09 18:54:18 UTC

[jira] [Comment Edited] (KAFKA-1044) change log4j to slf4j

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

Viktor Somogyi edited comment on KAFKA-1044 at 6/9/17 6:53 PM:
---------------------------------------------------------------

[~ewencp], thank you, started working on it.
I found two incompatibilities and I'm asking your advice in the resolution.
 * Fatal logging level: slf4j doesn't support it
 * kafka.utils.Log4jController: there are some log4j specific features used here that can't be replaced with a generic solution

I have two solutions for these:
 # we could simply use the log4j-over-slf4j package. This will redirect all Fatal logs to Error level and also provides some of the functionalities required by Log4jController (but not all).
    * Pros: a few lines of changes only, quite straightforward
    * Cons: loss of features. However Fatal can't be worked around so we have to accept that, but we also lose Log4jController.getLoggers as there is no way of collecting the current loggers by simply relying on slf4j. Also other methods' behaviour will change (no way to detect existing loggers in slf4j as far as I'm aware of it)
# we could separate off Log4jController into a separate module and have the users to put it on the classpath explicitly if they use log4j for logging. From Logging class we can instantiate it by reflection.
    * Pros: except Fatal logging level we keep all the features
    * Cons: more complicated and breaking, also requires documentation so users will be aware of this

I'll try to create PRs of both solutions (and they are rather work in progress, I just want to show approximate solutions) just in case if that is fine.


was (Author: viktorsomogyi):
[~ewencp], thank you, started working on it.
I found two incompatibilities and I'm asking your advice in the resolution.
 * Fatal logging level: slf4j doesn't support it
 * kafka.utils.Log4jController: there are some log4j specific features used here that can't be replaced with a generic solution

I have two solutions for these:
 # we could simply use the log4j-over-slf4j package. This will redirect all Fatal logs to Error level and also provides some of the functionalities required by Log4jController (but not all).
    * Pros: a few lines of changes only, quite straightforward
    * Cons: loss of features. However Fatal can't be worked around so we have to accept that, but we also lose Log4jController.getLoggers as there is no way of collecting the current loggers by simply relying on slf4j. Also other methods' behaviour will change (no way to detect existing loggers in slf4j as far as I'm aware of it)
# we could separate off Log4jController into a separate module and have the users to put it on the classpath explicitly if they use log4j for logging. From Logging class we can instantiate it by reflection.
    * Pros: except Fatal logging level we keep all the features
    * Cons: more complicated and breaking, also requires documentation so users will be aware of this

I'm attaching patches of both solutions (and they are rather work in progress, I just want to show approximate solutions) just in case

> change log4j to slf4j 
> ----------------------
>
>                 Key: KAFKA-1044
>                 URL: https://issues.apache.org/jira/browse/KAFKA-1044
>             Project: Kafka
>          Issue Type: Bug
>          Components: log
>    Affects Versions: 0.8.0
>            Reporter: shijinkui
>            Assignee: Viktor Somogyi
>            Priority: Minor
>              Labels: newbie
>
> can u chanage the log4j to slf4j, in my project, i use logback, it's conflict with log4j.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)