How to change log level from command line?

前端 未结 2 1180
暗喜
暗喜 2020-12-16 13:28

How can I change the log level in sbt at the command line without modifying the existing configuration?

相关标签:
2条回答
  • 2020-12-16 14:04

    As described in Change the logging level globally for sbt:

    To set the logging level before any commands are executed on startup, use -- before the logging level

    There are four logging levels:

    • debug
    • info
    • warn
    • error

    If you need one applied "at the command line without modifying the existing configuration", execute the sbt launcher with appropriate level prefixed with double dashes.

    jacek:~/oss/scalania
    $ sbt --debug
    [debug] > boot
    [debug] > reload
    [debug] > sbtStashOnFailure
    [debug] > onFailure load-failed
    [debug] > loadp
    [info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
    [debug] Running task... Cancelable: false, check cycles: false
    [debug]
    

    With sbt.boot.properties you may get sbt internal logs printed out, too. See Launcher Specification.

    0 讨论(0)
  • 2020-12-16 14:19

    For SBT 0.12:

    If you want to change the log level from the command line, you may do in sbt interactive mode without changing your build.sbt file or any configuration. Just type:

    > set logLevel := Level.Debug
    

    However if you are writing some scripts that will run in your server and you can't do interactively, you will have to create a boot.properties file setting the desired log level and pass this file in the command line, by running

    sbt -Dsbt.boot.properties=path-to-your-boot.properties
    

    Check the documentation for boot.properties here

    0 讨论(0)
提交回复
热议问题