Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove log4j and slf4j #124

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ val kafkaVersion = "1.1.0"
val confluentVersion = "4.1.0"
val akkaVersion = "2.5.11"

val slf4jLog4jOrg = "org.slf4j"
val slf4jLog4jArtifact = "slf4j-log4j12"

lazy val confluentMavenRepo = "confluent" at "https://packages.confluent.io/maven/"

lazy val commonSettings = Seq(
Expand All @@ -19,6 +16,10 @@ lazy val commonSettings = Seq(
homepage := Some(url("https://github.com/manub/scalatest-embedded-kafka")),
parallelExecution in Test := false,
logBuffered in Test := false,
excludeDependencies ++= Seq(
ExclusionRule("org.slf4j", "slf4j-log4j12"),
ExclusionRule("log4j", "log4j")
),
fork in Test := true,
javaOptions += "-Xmx1G",
scalacOptions += "-deprecation"
Expand All @@ -29,10 +30,10 @@ lazy val commonLibrarySettings = libraryDependencies ++= Seq(
"io.confluent" % "kafka-schema-registry" % confluentVersion,
"io.confluent" % "kafka-schema-registry" % confluentVersion classifier "tests",
"org.scalatest" %% "scalatest" % "3.0.5",
"org.apache.kafka" %% "kafka" % kafkaVersion exclude(slf4jLog4jOrg, slf4jLog4jArtifact),
"org.apache.kafka" %% "kafka" % kafkaVersion,
"com.typesafe.akka" %% "akka-actor" % akkaVersion % Test,
"com.typesafe.akka" %% "akka-testkit" % akkaVersion % Test,
slf4jLog4jOrg % slf4jLog4jArtifact % "1.7.25" % Test
"ch.qos.logback" % "logback-classic" % "1.2.3" % Test
)

lazy val publishSettings = Seq(
Expand Down Expand Up @@ -86,6 +87,6 @@ lazy val kafkaStreams = (project in file("kafka-streams"))
.settings(commonLibrarySettings)
.settings(releaseSettings: _*)
.settings(libraryDependencies ++= Seq(
"org.apache.kafka" % "kafka-streams" % kafkaVersion exclude(slf4jLog4jOrg, slf4jLog4jArtifact)
"org.apache.kafka" % "kafka-streams" % kafkaVersion
))
.dependsOn(embeddedKafka)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package net.manub.embeddedkafka

import org.apache.kafka.clients.consumer.{ConsumerRecord, KafkaConsumer}
import org.apache.kafka.common.KafkaException
import org.apache.log4j.Logger

import scala.util.Try

Expand All @@ -13,8 +12,6 @@ object ConsumerExtensions {

implicit class ConsumerOps[K, V](val consumer: KafkaConsumer[K, V]) {

private val logger = Logger.getLogger(getClass)

/** Consume messages from one or many topics and return them as a lazily evaluated Scala Stream.
* Depending on how many messages are taken from the Scala Stream it will try up to retryConf.maximumAttempts times
* to consume batches from the given topic, until it reaches the number of desired messages or
Expand All @@ -32,10 +29,8 @@ object ConsumerExtensions {
retryConf: ConsumerRetryConfig = ConsumerRetryConfig()
): Stream[T] = {
val attempts = 1 to retryConf.maximumAttempts
attempts.toStream.flatMap { attempt =>
val batch: Seq[T] = getNextBatch(retryConf.poll, topics)
logger.debug(s"----> Batch $attempt ($topics) | ${batch.mkString("|")}")
batch
attempts.toStream.flatMap { _ =>
getNextBatch[T](retryConf.poll, topics)
}
}

Expand Down
7 changes: 0 additions & 7 deletions embedded-kafka/src/test/resources/log4j.properties

This file was deleted.

12 changes: 12 additions & 0 deletions embedded-kafka/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<root level="OFF">
<appender-ref ref="STDOUT" />
</root>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package net.manub.embeddedkafka.streams

import net.manub.embeddedkafka.{EmbeddedKafka, EmbeddedKafkaConfig, UUIDs}
import org.apache.kafka.streams.{KafkaStreams, Topology}
import org.apache.log4j.Logger
import org.scalatest.Suite

/** Helper trait for testing Kafka Streams.
Expand All @@ -12,8 +11,6 @@ import org.scalatest.Suite
trait EmbeddedKafkaStreams extends EmbeddedKafka with TestStreamsConfig {
this: Suite =>

private val logger = Logger.getLogger(classOf[EmbeddedKafkaStreams])

/** Execute Kafka streams and pass a block of code that can
* operate while the streams are active.
* The code block can be used for publishing and consuming messages in Kafka.
Expand All @@ -34,7 +31,6 @@ trait EmbeddedKafkaStreams extends EmbeddedKafka with TestStreamsConfig {
withRunningKafka {
topicsToCreate.foreach(topic => createCustomTopic(topic))
val streamId = UUIDs.newUuid().toString
logger.debug(s"Creating stream with Application ID: [$streamId]")
val streams =
new KafkaStreams(topology, streamConfig(streamId, extraConfig))
streams.start()
Expand Down
7 changes: 0 additions & 7 deletions kafka-streams/src/test/resources/log4j.properties

This file was deleted.

12 changes: 12 additions & 0 deletions kafka-streams/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<root level="OFF">
<appender-ref ref="STDOUT" />
</root>
</configuration>