- Home /
Write to stdout from standalone?
Is there a way to write to the stdout from a standalone?
I have a console application that fires up a standalone in headless mode but I haven't been able to find a way to write to the stdout.
Here's the code that launches the standalone:
var startInfo = new ProcessStartInfo
{
FileName = Directory.GetCurrentDirectory() + "\\Server\\server.exe",
Arguments = "-batchmode",
RedirectStandardOutput = true,
UseShellExecute = false,
};
_process = new Process
{
StartInfo = startInfo
};
_process.OutputDataReceived += Received;
_process.Start();
I have the same problem because when you run the headless instance inside of docker container there is no nice way to collect logs
Answer by sergeytsaplin_wg · Jul 12, 2017 at 10:07 AM
I found the solution that works for me (in Linux for sure) - just pass -logFile /dev/stdout
to your executable file. Not sure that such trick will work in Windows
nice.
in our build scripts we're just using -logFile
with no path provided, which doesn't seem supported if you're going by the docs, but we do get nice unity build output in jenkins.
Answer by duncanisgoed · Oct 22, 2017 at 11:19 PM
I wrote a small tool in C# to do exactly this. You have to set the UNITY environment variable to your Unity executable ("C:\Program Files\Unity\Editor\Unity.exe" in most cases).
Then execute UnityCli.exe where you could use Unity.exe for example:
UnityCli.exe -batchmode -nographics -projectPath "%CD%\Unity" -executeMethod CI.BuildAll -quit -logFile build_unity.txt
The tool will automatically detect the "-logFile" parameter and redirect that output to the console while it happens so it's great for CI!
Your answer
![](https://koobas.hobune.stream/wayback/20220612084752im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to control MonoBehaviour lifecycle methods in test environment? 0 Answers
Help launching headless application? 1 Answer
Included DLLs? What are those? 1 Answer
Changing the default tag in Debug.Log for Unity 3D 1 Answer
How to get crash Reports that users send from Unity webplayer to Unity? 0 Answers