question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible issue with Logging trait

See original GitHub issue

I apologize in advance if I’m off base here, I know very (VERY) little about scala macros, and not much more about java’s invoking of virtual (?) / overridden methods.

I ran into issues where a parent class/trait extended the Logging trait and then the concrete class defined the logger method (manually or using slf4j LazyLogging or StrictLogging). Any usage of that logger in the parent class seems to be calling com.typesafe.scalalogging.Logger’s methods - which are “???” and throw a NotImplementedError, instead of calling the overridden macro method from the slf4j Logger.

I simplified this issue and replicated in the REPL:

scala> val logger = com.typesafe.scalalogging.slf4j.Logger(org.slf4j.LoggerFactory getLogger "test")
scala> (logger: com.typesafe.scalalogging.Logger) info "uheot"
scala.NotImplementedError: an implementation is missing
    at scala.Predef$.$qmark$qmark$qmark(Predef.scala:252)
    at com.typesafe.scalalogging.BaseLogger.info(Logger.scala:95)

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:1
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dukejansencommented, Jun 5, 2014

Beware @gshakhn: I believe the com.typesafe.scalalogging.slf4j.Logger class no longer exists in the new scala-logging artifact - it was renamed LazyLogger. So it’s likely you are picking up that class from the old scalalogging artifact which is being imported via a transitive dependency from some other library.

0reactions
ibalashovcommented, Jul 12, 2016

There’s no more API, just an implementation for SLF4J.

scala-logging-slf4j:2.1.2 still depends on troublesome scala-logging-api_2.11, which causes the following error:

java.lang.InstantiationError: com.typesafe.scalalogging.Logger

The workaround (for scala 2.11):

excludeDependencies ++= Seq(
  SbtExclusionRule("com.typesafe.scala-logging", "scala-logging-api_2.11")
)

Or should we not include scala-logging-slf4j altogether?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Possible issue with Logging trait #16 - GitHub
I ran into issues where a parent class/trait extended the Logging trait and then the concrete class defined the logger method (manually or...
Read more >
Problem when defining a Logging trait in scala - Stack Overflow
I could achieve this effect using loggers in companion objects: object A extends Logging; class A { import A._ log.debug("log from A") } ......
Read more >
Logging Trait - Apache Camel
The Logging trait is used to configure Integration runtime logging ... This trait is available in the following profiles: Kubernetes, Knative, OpenShift.
Read more >
Logging - OWASP Cheat Sheet Series
Which events to log¶ · Sequencing failure · Excessive use · Data changes · Fraud and other criminal activities · Suspicious, unacceptable or...
Read more >
Scala Logging | How Logging Work in Scala with Examples
Inside this package com.typesafe.scalalogging it provides us two traits which are Strict Logging and Lazy Logging and they are responsible to define the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found