本文整理匯總了C#中NLog.Targets.FileTarget.WriteAsyncLogEvents方法的典型用法代碼示例。如果您正苦於以下問題:C# FileTarget.WriteAsyncLogEvents方法的具體用法?C# FileTarget.WriteAsyncLogEvents怎麽用?C# FileTarget.WriteAsyncLogEvents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NLog.Targets.FileTarget
的用法示例。
在下文中一共展示了FileTarget.WriteAsyncLogEvents方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: BatchErrorHandlingTest
public void BatchErrorHandlingTest()
{
var fileTarget = new FileTarget { FileName = "${logger}", Layout = "${message}" };
fileTarget.Initialize(null);
// make sure that when file names get sorted, the asynchronous continuations are sorted with them as well
var exceptions = new List<Exception>();
var events = new[]
{
new LogEventInfo(LogLevel.Info, "file99.txt", "msg1").WithContinuation(exceptions.Add),
new LogEventInfo(LogLevel.Info, "", "msg1").WithContinuation(exceptions.Add),
new LogEventInfo(LogLevel.Info, "", "msg2").WithContinuation(exceptions.Add),
new LogEventInfo(LogLevel.Info, "", "msg3").WithContinuation(exceptions.Add)
};
fileTarget.WriteAsyncLogEvents(events);
Assert.Equal(4, exceptions.Count);
Assert.Null(exceptions[0]);
Assert.NotNull(exceptions[1]);
Assert.NotNull(exceptions[2]);
Assert.NotNull(exceptions[3]);
}