asp.netmvcに非同期書き込みログが必要です 。コードは次のようになります。
public ActionResult Index()
{
byte[] buffer = Encoding.UTF8.GetBytes(string.Format("log:{0}{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff"), Environment.NewLine));
FileStream fs = new FileStream(@"c:\log.txt", FileMode.Append, FileAccess.Write, FileShare.Write, 1024, true);
fs.BeginWrite(buffer, 0, buffer.Length, ar =>
{
fs.EndWrite(ar);
fs.Close();
}, null);
}
しかし、結果は私が期待したものではなく、一部のログが記録されていません、誰かがコードの何が問題になっているのか教えてもらえますか