0

enter image description hereI am new to scala and I am doing some basic programs. I am trying to add the Scala Logging library by adding the following library dependencies in build.sbt:

"ch.qos.logback" % "logback-classic" % "1.1.7"

"com.typesafe.scala-logging" %% "scala-logging" % "3.4.0"

But the logging libraries are not getting downloaded and present under external libraries.

The program I am working with is

package com.allaboutscala.chapter.one.tutorial_10

object HelloWorldWithScalaLogging extends App with LazyLogging{

  logger.info("hello from logger")
}

Please find the screenshot attached.

It would be great if someone can guide me on this issue.

Ramesh Maharjan
  • 41,071
  • 6
  • 69
  • 97
Nikhil
  • 11
  • 7
  • Possible duplicate of [Scala logging error, com.typesafe.scalalogging.LazyLogging.$init$ method not found](https://stackoverflow.com/questions/45998740/scala-logging-error-com-typesafe-scalalogging-lazylogging-init-method-not-fou) – Ramesh Maharjan Jun 29 '18 at 08:08
  • To be more clear: it isn't a duplicate of the question, but the answer there should fix the problem. – Alexey Romanov Jun 29 '18 at 08:46

1 Answers1

3

The issue with the versions, we're importing. Try this code

libraryDependencies ++= Seq(
  "com.typesafe.scala-logging" %% "scala-logging" % "3.9.3",
  "ch.qos.logback" % "logback-classic" % "1.2.3"
)

Here is the more info about this dependency: About Scala Logging

Here is the code snippt:

package hello

import com.typesafe.scalalogging.{LazyLogging, Logger}

object Hello extends App with LazyLogging{
  println("Programming is a fun");
  lazy override val logger = Logger("name");
  logger.info("hello Bug");
}
Mr Sindhu
  • 316
  • 2
  • 11