2

This is probably a stupid question, but my scala knowledge is a bit lacking. I'm trying to implement structured logging in scala, and we're using slf4j/logback/logstash. I came across the following post: How does SLF4J support structured logging Which describes how to do it:

import static net.logstash.logback.argument.StructuredArguments.*;

/*
 * Add "name":"value" ONLY to the JSON output.
 *
 * Since there is no parameter for the argument,
 * the formatted message will NOT contain the key/value.
 *
 * If this looks funny to you or to static analyzers,
 * consider using Markers instead.
 */
logger.info("log message", keyValue("name", "value"));

Obviously this is java code, not scala. I've converted it over, but I can't get it to find net.logstash.logback.argument.StructuredArguments.KeyValue. I'm guessing this is because it's not being included in the build, but this is where I'm tripping up.

I'm using sbt, and I'm including what I expect the package to be:

"net.logstash.logback" %% "logstash-logback-encoder" % VersionOf.`logstash`

However sbt cannot find that package (version is 1.2.1). What's also confusing me is that our other dependencies for logback are pulled from the group id: ch.qos.logback. I don't really understand what ch.qos.logback is and why it's different from net.logstash.logback.

Long story short, what package do I need to import with sbt so that I can use StructuredArguments/KeyValues for my logging?

Andy
  • 3,228
  • 8
  • 40
  • 65

0 Answers0