How to get logging working in scala unit tests with testng, slf4s, and logback

后端 未结 4 922
被撕碎了的回忆
被撕碎了的回忆 2020-12-30 23:51

I\'m new to Scala, and not that familiar with recent developments in Java, so I am having what I assume is a basic problem.

I\'m writing some Scala code, and testing

4条回答
  •  说谎
    说谎 (楼主)
    2020-12-31 00:42

    I had the same issue. Ended up just instantiating an empty logger in the class definition.

    If I applied my method to your code then it would be,

    import com.weiglewilczek.slf4s.{Logger, Logging}
    
    class MyClass with Logging {
       val _ = Logger("") // <--Solved problem
    
       def doSomething() {
          logger.debug("Hello world")
      }
    }
    

    Note that I am very new to scala so I don't know the full implications of what I have just done.

提交回复
热议问题