Search code examples
scalasbt

Change the sbt log level on only my machine in perpetuity?


Every time I use sbt the first thing I do is set the log level to Error:

$ sbt
// ... sbt loads
[my_project] $ error
[my_project] $

Several places on SO and elsewhere recommend adding this to either your build.sbt or your sbt.boot.properties:

set logLevel in run := Level.Error 

But I'm working in a shared project with many developers and I don't want to change the log level for everyone, just me! I do currently use SBT_OPTS to tailor sbt's memory usage on my machine, and this may potentially be an option but I can't find any guidance on what format to pass options via SBT_OPTS except for Java things like pass -Dkey=val directly to the java runtime and memory parameters like -Xmx8G.

sbt --help indicates that .sbtopts may also be a potential option:

  .sbtopts            if this file exists in the current directory, its contents
                      are prepended to the runner args

But as far as I can tell there are no method to specify command-line "runner args" that set the log level to Error, only for setting the log level to debug via --debug.

I'm a little stumped, I've identified at least two potential avenues (SBT_OPTS and .sbtopts) for passing machine-specific customization to sbt, but do either of these support setting the log level to Error? Or is there a third avenue I'm missing, maybe some elusive ~/.sbt, that I could use to set my machine's sbt log level to Error?


Solution

  • Put the following in $HOME/.sbt/1.0/global.sbt

    logLevel := Level.Error
    

    All available log level options are:

    • Error
    • Warn
    • Info
    • Debug

    Thanks @maxkar for leading me to this solution