Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppressing sbt debug output

Tags:

scala

sbt

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
like image 889
synapse Avatar asked May 14 '13 19:05

synapse


2 Answers

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.

like image 167
EthanP Avatar answered Nov 12 '22 03:11

EthanP


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.

like image 2
Shaun the Sheep Avatar answered Nov 12 '22 04:11

Shaun the Sheep