Logging in Scala

前端 未结 14 2050
南旧
南旧 2020-12-07 06:51

What is a good way to do logging in a Scala application? Something that is consistent with the language philosophy, does not clutter the code, and is low-maintenance and uno

14条回答
  •  盖世英雄少女心
    2020-12-07 07:22

    I find very convenient using some kind of java logger, sl4j for example, with simple scala wrapper, which brings me such syntax

    val #! = new Logger(..) // somewhere deep in dsl.logging.
    
    object User with dsl.logging {
    
      #! ! "info message"
      #! dbg "debug message"
      #! trace "var a=true"
    
    }
    

    In my opinion very usefull mixin of java proven logging frameworks and scala's fancy syntax.

提交回复
热议问题