13

How do I suppress SBT's debug messages? They are logged to stdout so running a project produces this:

$ cat src/main/scala/Hello.scala 
object Hello {
  def main(args: Array[String]) {
    Console.println("Hello sbt")
  }
}

$ sbt run > out.txt

$ cat out.txt
[info] Set current project to hello (in build file:/home/synapse/projects/algs2/)
[info] Running Hello 
Hello sbt
[success] Total time: 1 s, completed May 14, 2013 11:39:23 PM
synapse
  • 5,588
  • 6
  • 35
  • 65
  • 1
    Did you ever find a solution? I'm struggling with this as well. – dcb Nov 13 '13 at 23:22
  • 2
    Possible duplicate of [How to suppress info and success messages in sbt?](http://stackoverflow.com/questions/9968300/how-to-suppress-info-and-success-messages-in-sbt) – Chris Martin Jan 12 '16 at 07:56

3 Answers3

8

As mentioned in this reference also linked by the other answer, it is possible to change logging level before arriving at the sbt console.

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

For example

$ sbt --error "runMain my.pckg.Main"

However you still get the [success] message logged at the end. For silencing that, consider piping into grep -v.

EthanP
  • 1,663
  • 3
  • 22
  • 27
2

You can alter the logging level as described here. So you can changed the logging level to Warn:

> run
[info] Running Server
Port is: null
Embedded server running on port 8080. Press any key to stop.

[success] Total time: 3 s, completed 14-May-2013 21:02:31
>
> set logLevel in run := Level.Warn
...
[info] Reapplying settings...
[info] Set current project to server (in build file:/Users/me/myproject/)
> run
Port is: null
Embedded server running on port 8080. Press any key to stop.

and you no longer get the info messages printed for the run command. You can add the setting to your build file to make it permanent.

Shaun the Sheep
  • 22,353
  • 1
  • 72
  • 100
  • 7
    The build.sbt consists of a single line logLevel := Level.Error and sbt run still outputs info and success messages – synapse May 14 '13 at 20:20
0

You can add the Log Level properties to the Global SBT properties. This works for sbt version 1.x

File : ~/.sbt/1.0/global.sbt
logLevel := Level.Warn

shellPrompt := { state =>
  "sbt (%s)> ".format(Project.extract(state).currentProject.id)
}
Vishnu667
  • 768
  • 1
  • 16
  • 39