下面是主要代码,主要对web的日志进行记录和显示。
- using System;
- using System.Collections;
- using System.Configuration;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.HtmlControls;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Xml.Linq;
- using System.Diagnostics;
- using Microsoft.Practices.EnterpriseLibrary.Common;
- using Microsoft.Practices.EnterpriseLibrary.Logging;
- namespace WebSite
- {
- public partial class LogWrite : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void btnLogWrite_Click(object sender, EventArgs e)
- {
- LogEntry logEntry = new LogEntry();
- logEntry.EventId = 11;
- logEntry.Priority = 1;
- logEntry.Message = "eee";
- Logger.Write(logEntry);
- }
- protected void btnShowTextLog_Click(object sender, EventArgs e)
- {
- Process traceFileViewerProcess = new Process();
- traceFileViewerProcess.StartInfo.FileName = "Notepad.exe";
- traceFileViewerProcess.StartInfo.Arguments = "Trace.log";
- traceFileViewerProcess.Start();
- }
- protected void btnShowSystemLog_Click(object sender, EventArgs e)
- {
- Process traceFileViewerProcess = new Process();
- string executable = Environment.ExpandEnvironmentVariables(@"%SystemRoot%\system32\eventvwr.msc");
- traceFileViewerProcess.StartInfo.FileName = executable;
- traceFileViewerProcess.StartInfo.Arguments = "/s";
- traceFileViewerProcess.Start();
- }
- }
- }