使用 c# 在 Windows 事件日志上写入问题。
public static void writeToEventLog(string msgGrid, string msgIntern, EventLogEntryType entryType)
{
string grp = "Application"; // Fixed because cant create new but happy if bellow works.
if (!EventLog.SourceExists(msgGrid)) { EventLog.CreateEventSource(msgGrid, grp); }
EventLog.WriteEntry(msgGrid, msgIntern, entryType);
}
// 以下代码不会在事件日志中添加条目:
string msgGrid = "pdtidtijejrnexhr";
string msgIntern = "*-* [Dt:2013-10-31 11:41:10.00][digkufdufe:{[<2013-10-31 11:41:09> {jpdriskrt01} jpdriskrt01[172.22.3.70:57010]> [pdtidhry jrnecidr]]} : {}] >>#[eydshr:(rhrdhruiweirts.hrt.krt.krtjelr.jt.jpdrtjelkrhtw.<dnjr>b__1)]>>#[jpdrtjelkrhtw]\\[pdtidtijejrnexhr]\r\n";
writeToEventLog(msgGrid, msgIntern, EventLogEntryType.FailureAudit);
// 下面的代码工作正常:
writeToEventLog("t1", "t2", EventLogEntryType.FailureAudit);
日志内容或大小有一些限制?