18

When I do sbt run I see some header and footer info which I would like to get rid of:

$ sbt run 
[info] Set current project to XXX (in build file:/path/to/dir/)
<actual program output goes here; stuff I care about>
[success] Total time: 68 s, completed Apr 1, 2012 7:30:45 PM
$ 

How can I get rid of those 2 additional lines (i.e., the [info] and [success] lines)? Are there some build.sbt configuration settings available to do that? Ideally, I don't want to have another tool/dependency just to get rid of those 2 lines.

Following is a list of things I have tried:

  • Set run logLevel to Warn
  • Set Global logLevel to Warn
  • Set -Dsbt.log.noformat=true

The workaround that I am currently using: Copy the java invocation that sbt generates (by doing ps or top) as a result of doing fork in run := true and manually run that java command directly on the command line.

It would be much cleaner if sbt could be told not to print those lines.

  • Scala version: 2.9.1
  • SBT version: 0.11.1
Arvind K
  • 181
  • 1
  • 3
  • 1
    Do you always start your application like this? sbt is a build tool and not an application runner. If I am right with my assumption I would suggest you to instead build and package your application and run it with `scala. – drexin Apr 01 '12 at 21:20
  • 1
    Thanks @drexin yes I realized there are better ways to fire it up. I am now using [one-jar](https://github.com/sbt/sbt-onejar). Pretty cool and does exactly what I've been wanting to do: simple and straightforward invocation post development. – Arvind K Apr 02 '12 at 04:17

4 Answers4

17

sbt 1.x, sbt 0.13.13+

Use -warn or -error. See Fixes with compatibility implications for sbt 0.13.13 release:

it is strongly encouraged to migrate to the single hyphen options: -error, -warn, -info, and -debug

sbt 0.13.1

To disable info messages run SBT with --warn or --error command line options.

To disable [success] messages set showSuccess to false.

Bringing it all together, it gives you the following options:

  • On command line use the following:

      $ sbt --error 'set showSuccess := false' run
    
  • In build.sbt add showSuccess := false

      $ cat build.sbt
      showSuccess := false
    

and execute sbt --error run.

Seth Tisue
  • 29,985
  • 11
  • 82
  • 149
Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
7

As Jacek mentioned in his response, in build.sbt you can add showSuccess := false to suppress the [success] message. To suppress the [info] message, I'd set the logLevel to Level.Warn for the run configuration only. Putting it together, you want to add these lines to build.sbt:

showSuccess := false

logLevel in run := Level.Warn
Adam Dingle
  • 3,114
  • 1
  • 16
  • 14
4

You should be able to get rid of the "Set current project" line by adding this to your build.sbt file:

onLoadMessage := ""
Seth Tisue
  • 29,985
  • 11
  • 82
  • 149
1

This is an old question that comes up at top of web searches, but gives the wrong answer. After this change was recently merged, the prescribed way to suppress interactive noise is by passing two flags to sbt:

sbt -batch -error ...

Works for me in sbt 1.8.0

Igor Urisman
  • 717
  • 1
  • 6
  • 22