Closed eouree closed 3 years ago
You're close, but because you're using the 'using' statement for the StreamWriter the writer gets disposed immediately after the snippet. It should work if you change it to
string fileName = Environment.CurrentDirectory + @"\Log.txt";
StreamWriter writer = new StreamWriter(fileName);
BinanceSocketClient.SetDefaultOptions(new BinanceSocketClientOptions
{
ApiCredentials = new ApiCredentials(mode.ApiKey, mode.ApiSecret),
AutoReconnect = true,
ReconnectInterval = TimeSpan.FromSeconds(15),
BaseAddress = "wss://testnet.binance.vision/",
LogVerbosity = LogVerbosity.Debug,
LogWriters = new List<TextWriter> {Console.Out, writer}
});
Remember to close/dispose the writer when your program closes.
Thank you again
Hello All,
I tried to add another log writer apart the Console.Out for writing the logs to a text file as well. I used the below code with no success. Can anyone help me on this matter? Am i doing something wrong?
Besides the above code, i also tried the Console.SetOut as here https://www.dotnetperls.com/console-setout but again didn't work.
Thanks