Comments (6)
@analytically - looks like the folks over at reactive-kafka
figured it out - akka/alpakka-kafka#99.
Basically, if your dependency tree includes the older scala-logging-slf4j
artifact you'll see this exception.
Answer: exclude("com.typesafe.scala-logging", "scala-logging-slf4j_2.11")
from scala-logging.
I'll leave my solution for Databricks logging problem for further reference.
tl;dr:
Databricks uses old com.typesafe.scalalogging version 2.1.2. For newer ones, this is repaired.
Solution
Scalalogging uses org.slf4j.Logger in the background. Let's do our own Logger trait based on the latter:
package yourPackage
import org.slf4j.{Logger, LoggerFactory}
// Serializable logger
trait MyLogging {
@transient
protected lazy val logger: Logger =
LoggerFactory.getLogger(getClass.getName)
}
Then let's use this trait instead of com.typesafe.scalalogging.LazyLogging.
trait YourSparkApp extends yourPackage.MyLogging
{
def main(argList: Array[String]): Unit = {
implicit val logger: Logger = this.logger // For implicit usage.
logger.info("This should work.")
...
}
}
Longer explanation
The currently newest Databricks 5.5 (Scala 2.11) uses old version of com.typesafe.scalalogging 2.1.2 as shown in
https://docs.databricks.com/release-notes/runtime/5.5.html#installed-java-and-scala-libraries-scala-2-11-cluster-version
To my knowledge, it is difficult to override this logger with other packages or versions in Spark. (I think there is an experimental flag for spark-submit.)
Logger should not be serialized, thus, it needs to be transient. However, 2.1.2 does not do this as shown here:
2.1.2: https://github.com/lightbend/scala-logging/blob/v2.1.2/scala-logging-slf4j/src/main/scala/com/typesafe/scalalogging/slf4j/Logging.scala#L28
As explained in this issue, in the newer versions, this is repaired. For instance 3.9.0: https://github.com/lightbend/scala-logging/blob/v3.9.0/src/main/scala/com/typesafe/scalalogging/Logging.scala#L27
Nevertheless, this currently does not help with Databricks because of the old library version used.
Hence, we need to create our own Logging trait based on org.sljf4j and inherit this (instead of com.typesafe.scalalogging.LazyLogging).
We do not even need to change dependencies in Maven or SBT because org.slf4j is already included in the scalalogging library.
from scala-logging.
Do you see the same using StrictLogging?
from scala-logging.
Yes, I see that same error intermittently using the StrictLogging
interface.
java.lang.InstantiationError: com.typesafe.scalalogging.Logger
at com.typesafe.scalalogging.Logger$.apply(Logger.scala:32)
at com.typesafe.scalalogging.StrictLogging$class.$init$(Logging.scala:38)
at com.hivehome.kafka.connect.sqs.SQSSourceTask.<init>(SQSSourceTask.scala:36)
I am also using 3.5.0
from scala-logging.
@analytically why was this issue closed? I don't see a workaround or a commit addressing this problem (which I am now seeing too).
from scala-logging.
I'm unable to reproduce it.
from scala-logging.
Related Issues (20)
- request: Declare version scheme / policy HOT 2
- `when***Enabled()` methods are missing in LoggerTakingImplicitImpl HOT 1
- ditch Travis-CI, switch to GitHub Actions
- Unpatched vulnerability - https://jira.qos.ch/browse/LOGBACK-1591 HOT 4
- Logging Macro Doesn't Support Scala2 + Scala3 Simultaneously HOT 2
- Example for AnyLogging
- Example for StrictLogging
- Include a way to create Logger always with the name of the class into which it is defined
- Remove type annotation warnings from test files
- Current release is compiled for Java 8 but requires Java 9 in bundle manifest HOT 7
- Varargs compilation error as of v3.9.5 HOT 3
- Disable logging HOT 1
- Expose the SLF4J2 LoggingEventBuilder "Fluent" API
- Illegal Update to non-static final field - Gradle 7.6 HOT 1
- Fix CVE-2022-36944 for scala 2.13.x before 2.13.9 HOT 15
- String Interpolation Limitations
- Bump slf4j-api dependency to 2.x HOT 3
- New volunteer maintainer(s) needed HOT 9
- Message formatting (interpolation) with last argument of Throwable
- In Scala3, using a non-inline variable-length parameter doesn't print correctly HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scala-logging.