Idiomatic way of logging in Kotlin

后端 未结 16 1432
情歌与酒
情歌与酒 2020-12-07 07:34

Kotlin doesn\'t have the same notion of static fields as used in Java. In Java, the generally accepted way of doing logging is:

public class Foo {
    privat         


        
16条回答
  •  太阳男子
    2020-12-07 07:42

    I have heard of no idiom in this regard. The simpler the better, so I would use a top-level property

    val logger = Logger.getLogger("package_name")
    

    This practice serves well in Python, and as different as Kotlin and Python might appear, I believe they are quite similar in their "spirit" (speaking of idioms).

提交回复
热议问题