How to redirect the output of a command to a file?

What are the means of redirecting output from one command to a file in sbt?

I could exit sbt, do sbt mycommand > out.txt and run it again, but I wonder if there is an alternative?

+7
sbt
source share
1 answer

In Add a custom log , you can find additional information about what is required in order to have your own log that logs to a file - use extraLoggers and add an instance of sbt.AbstractLogger that performs the save.

Can you find my answer Display timestamp for debug mode in SBT? . Example copied here:

 def datedPrintln = (m: String) => println(s"+++ ${java.util.Calendar.getInstance().getTime()} $m") extraLoggers := { val clientLogger = FullLogger { new Logger { def log(level: Level.Value, message: => String): Unit = if(level >= Level.Info) datedPrintln(s"$message at $level") def success(message: => String): Unit = datedPrintln(s"success: $message") def trace(t: => Throwable): Unit = datedPrintln(s"trace: throwable: $t") } } val currentFunction = extraLoggers.value (key: ScopedKey[_]) => clientLogger +: currentFunction(key) } 
+4
source share

All Articles