C# 如何将断言发送到日志文件?

C# 如何将断言发送到日志文件?,c#,C#,我的代码中有一些断言,它们在我的ninjatrader中创建弹出窗口。如何防止弹出窗口并将相同的消息发送到日志文件 case MarketPosition.Long: { Trace.Assert(exitStopOrderLong!= null,"exitStopOrderLong is null"); Trace.Assert(exitStopOrderLong.OrderStat

我的代码中有一些断言,它们在我的ninjatrader中创建弹出窗口。如何防止弹出窗口并将相同的消息发送到日志文件

case MarketPosition.Long:
                {
                    Trace.Assert(exitStopOrderLong!= null,"exitStopOrderLong is null");
                    Trace.Assert(exitStopOrderLong.OrderState==OrderState.Accepted,string.Format("exitStopOrderLong is in invalid state{0}",exitStopOrderLong.OrderState));
                    double stopPrice=Instrument.MasterInstrument.Round2TickSize(Low[1]) -Instrument.MasterInstrument.TickSize/2 ;
                    ChangeOrder(exitStopOrderLong, exitStopOrderLong.Quantity, 0, stopPrice);


                    break;
                }

答案要简单得多。添加到app.config并放置目标日志文件名