Command line feedback

I am running a Unity Editor function from the commandline and I am looking to get feedback to the console/terminal instead of only the "Editor.Log" file. Basically anything that comes out of the Debug.log would be great, especially to see where things are failing.

I've tried the C# "System" but it seems to conflict with another Unity object.

Any suggestions? TIA.

Empty -logFile option forces Unity to output log to console:

$UNITY_BIN -quit -batchmode -logFile -projectPath ...

This is what I’ve done as a workaround:

On Unix based system (such as OSX) you can create a shell script to monitor the Editor.log and output to the stdout, ex:

unity_stdout.sh

#!/bin/sh
tail -F ~/Library/Logs/Unity/Editor.log &
/Applications/Unity/Unity.app/Contents/MacOS/Unity "$@"
EXITCODE="$?"
kill %1
exit "$EXITCODE"

Usage:

./unity_stdout.sh -batchMode ...etc

It launches tail in monitor mode as a background task, launches Unity passing the command line arguments, store it’s exit code, kills tail and return the saved exit code.

However all the Editor.log will be dumped, this include calls to Debug.Log() and Console.WriteLine().

If you want to choose what will be dumped to the console, instead open a file stream in Unity to some file like My.log, write to it and modify the shell script to monitor your file instead of the Unity.log

try

System.Console.WriteLine(yourString)

if that doesn't work, you'll have to reroute the standard console output (only need to do it once):

System.IO.StreamWriter standardOutput = new System.IO.StreamWriter(System.Console.OpenStandardOutput());
standardOutput.AutoFlush = true;
System.Console.SetOut(standardOutput);

Then you can use System.Console.WriteLine(yourString);

actually Joachim Ante had a great answer that works from another answer:

string[] System.Environment.GetCommandLineArgs()