如何从命令行更改日志级别?

Rad*_*lář 15 sbt

如何在不修改现有配置的情况下在命令行中更改sbt中的日志级别?

Jac*_*ski 18

更改 sbt的全局日志记录级别中所述:

要在启动时执行任何命令之前设置日志记录级别,请在日志记录级别之前使用 -

有四个日志记录级别:

  • 调试
  • 信息
  • 警告
  • 错误

如果您需要在命令行中应用"而不修改现有配置",请执行sbt具有前缀为双短划线的适当级别的启动器.

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]
Run Code Online (Sandbox Code Playgroud)

随着sbt.boot.properties你可能会sbt打印出内部日志了.请参阅启动器规范.

  • 我使用了`sbt --info test`,但它仍然在调试级别记录。 (2认同)

Vin*_*ana 10

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
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

Check the documentation for boot.properties here