将 sbt 与 fork ( fork in run := true
) 一起使用时,从我的应用程序到 stdout 的每个输出都以 [info]
为前缀;输出到 stderr 的前缀是 [error]
.
当使用输出到 stderr 的 Java 日志框架时,这种行为有点烦人。生成的调试消息通常如下所示:
[error] [main] INFO MyClass ...
[error] [main] DEBUG MyClass ...
我想抑制这些前缀,就像在不 fork 的情况下运行代码一样。我试过的:
sbt -Dsbt.log.noformat=true
在 sbt 启动脚本中。但这只会删除彩色的 ANSI 输出;前缀仍然存在,只是没有颜色 logLevel in run := Level.Error
在 build.sbt
.这似乎对使用 fork 进行日志记录没有任何影响。 有没有办法抑制前缀?
最佳答案
您需要设置 output strategy你的项目。
在我的扩展构建中,我有以下设置:
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
)
关于scala - sbt:抑制标准输出中的日志前缀,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14504572/