Reputation: 26570
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:
sbt -Dsbt.log.noformat=true
in the sbt launch script. But this only removes colored ANSI output; prefixes are still there just without colorlogLevel in run := Level.Error
in build.sbt
. This does not seem to have any influence on logging with forking.Is there any way to suppress the prefixes?
Upvotes: 13
Views: 2275
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