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.

SLF4J log level is only error in 1.0.0-RC3

See original GitHub issue

steps

Execute a task that calls a slf4j logger (e.g. from a dependency or directly from the task)

  def testLoggingTask: Def.Initialize[Task[Unit]] = Def.task {
    val log: Logger = streams.value.log

    log.info("sbt streams")

    val logger = LoggerFactory.getLogger("SLF4J logger")
    logger.info("slf4j logger")
    logger.warn("slf4j logger")
    logger.error("slf4j logger")
  }

problem

With sbt 1.0.0-RC3 logging output is different than in sbt 0.13.16. Only errors is logged.

[info] Set current project to root (in build file:/C:/Users/-/AppData/Local/Temp/sbt_c768fa02/testLogging/)
[info] sbt streams
[pool-5-thread-1] ERROR SLF4J logger - slf4j logger

expectation

Logging output is reported for all log levels that are configured, e.g. logLevel := Level.Debug where info is the default if not configured.

[info] Set current project to root (in build file:/C:/Users/-/AppData/Local/Temp/sbt_b9e14e18/testLogging/)
[info] sbt streams
[pool-4-thread-1] INFO SLF4J logger - slf4j logger
[pool-4-thread-1] WARN SLF4J logger - slf4j logger
[pool-4-thread-1] ERROR SLF4J logger - slf4j logger

notes

The possibility to set the log-level for specific packages/classes used in plugins via a system property is not working with 1.0.0-RC3 neither. Should mention that I have slf4j-simple and slf4-api in the classpath when running with sbt 0.13.16.

initialize ~= { _ =>
	sys.props += (("org.slf4j.simpleLogger.log.my.package", "info"))
}

sbt version: 1.0.0-RC3

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
albuchcommented, Jan 2, 2019

@eed3si9n could you point in any direction where to start looking? This is getting more and more annoying without even having a workaround.

0reactions
anilkumarmylacommented, Jan 28, 2019

I could get the testLoggingTask working by passing -Dlog4j2.level=debug to sbt.

Ref https://logging.apache.org/log4j/2.0/manual/configuration.html#SystemProperties

The crux of the problem appears to be log4j2 not setting root logging level to the level defined in sbt (logLevel) . You can pass -Dlog4j2.debug to sbt and you can see this in motion

WARN StatusLogger No Root logger was configured, creating default ERROR-level Root logger with Console appender
Read more comments on GitHub >

github_iconTop Results From Across the Web

SLF4J - Logging regardless of the log level - Stack Overflow
I use DEBUG level logging on development and ERROR level logging on the production environment. But there are some messages that I want...
Read more >
SLF4J FAQ
SLF4J is only a facade, meaning that it does not provide a complete logging solution. Operations such as configuring appenders or setting logging...
Read more >
Logging in Spring Boot - Baeldung
So, if we set the logging levels using Logback, Spring Boot, and environment variables at the same time, the log level will be...
Read more >
Log4j Levels Example - Order, Priority, Custom Filters
When we define logger level, anything having higher priority logs are ... to log only INFO and FATAL events but not WARN and...
Read more >
Log4j – Changes - Apache Logging Services
Fix NPE in `log4j-to-jul` in the case the root logger level is null. ... LocalizedMessage logs misleading errors on the console.
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