bluenote10
bluenote10

Reputation: 26570

sbt: suppressing logging prefix in stdout

When using sbt with forking (fork in run := true), every output from my application to stdout is prefixed by [info]; output to stderr is prefixed with [error].

This behavior is somewhat annoying when using a Java logging framework which outputs to stderr. The resulting debug messages typically look like this:

[error] [main] INFO MyClass ...
[error] [main] DEBUG MyClass ...

I would like to suppress these prefixes like when running the code without forking. What I tried:

Is there any way to suppress the prefixes?

Upvotes: 13

Views: 2275

Answers (2)

samthebest
samthebest

Reputation: 31523

Can do

sbt -error ...

and also

sbt -warn ...

Upvotes: 0

Andy
Andy

Reputation: 5218

You need to set the output strategy of your project.

In my extended build I have the following settings:

settings = Project.defaultSettings ++ Seq(
  fork                  :=   true, // Fork to separate process
  connectInput in run   :=   true, // Connects stdin to sbt during forked runs
  outputStrategy        :=   Some(StdoutOutput) // Get rid of output prefix
  // ... other settings
)

Upvotes: 16

Related Questions