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?
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
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With