c++ - 将exe输出实时保存到文本文件
问题描述
我有一个连接到服务器并实时输出结果的 exe 文件。有什么办法,使用 Windows,我可以将此 exe 输出的结果存储到文本文件中,并以半实时方式更新?我试过example.exe > log.txt
了,但它返回
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.Console.SetCursorPosition(Int32 left, Int32 top)
at MinecraftClient.ConsoleIO.Write(String text)
at MinecraftClient.ConsoleIO.WriteLine(String line)
at MinecraftClient.McTcpClient.OnConnectionLost(DisconnectReason reason, String message)
at MinecraftClient.Protocol.Handlers.Protocol18Handler.Updater()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
解决方案
You can use something like that:
mycommand.exe param 2>&1 > myfile.txt
And it will create the myfile.txt
at startup and fill it.
The 2
correspond to error log, and &1
add basic log (not debug).
推荐阅读
- three.js - @react-three/fiber:如何为阴影相机创建助手?
- c# - 如何允许在 POST 正文中使用枚举描述
- angular-leaflet-directive - 是否可以让 Azure 地图成为 Leaflet 中的底图
- c++ - 如何使用带有多字符串参数的工厂方法来创建模板类?
- geopandas - 使用 Geopandas 读取 Shapefile 时缺少列
- heatmap - 如何在r上的热图相关矩阵中取出两个变量
- timescaledb - 尝试设置 timescaledb-ha 版本
- python - 读取文本文件时如何更正列之间的空格?
- java - Java中的“按值传递”或“按引用传递”?
- flutter - 图像列表不显示在 Flutter-web 中