呵呵.不给分问题也没那么严重啊:-)asp.net本身提供了把错误记录到windows事件日志的功能.请参考System.Diagnostics名称空间.
这里有个例子:<%@ Import Namespace="System.Diagnostics" %>
<script Language="c#" runat="server" >
void EntrytoLog()
{
int[] array = new int[9];
for(int intCounter=0; intCounter <= 9;intCounter++)
{
array[intCounter] = intCounter;
Response.Write("The value of the counter is:" + intCounter + "<br>");
}
}
void Page_Error(object sender, EventArgs e)
{
string errorMessage = "Error occurred" + Server.GetLastError();
Server.ClearError();
string LogName = "MyApplicationLog";
string SourceName = "MyApplicationSource";
if (!(EventLog.SourceExists(SourceName)))
{
EventLog.CreateEventSource(SourceName, LogName);
}
// Insert into Event Log;
EventLog MyLog = new EventLog();
MyLog.Source = SourceName;
MyLog.WriteEntry(errorMessage, EventLogEntryType.Error);
}
</script>
<%
EntrytoLog();
%>
这里有个例子:<%@ Import Namespace="System.Diagnostics" %>
<script Language="c#" runat="server" >
void EntrytoLog()
{
int[] array = new int[9];
for(int intCounter=0; intCounter <= 9;intCounter++)
{
array[intCounter] = intCounter;
Response.Write("The value of the counter is:" + intCounter + "<br>");
}
}
void Page_Error(object sender, EventArgs e)
{
string errorMessage = "Error occurred" + Server.GetLastError();
Server.ClearError();
string LogName = "MyApplicationLog";
string SourceName = "MyApplicationSource";
if (!(EventLog.SourceExists(SourceName)))
{
EventLog.CreateEventSource(SourceName, LogName);
}
// Insert into Event Log;
EventLog MyLog = new EventLog();
MyLog.Source = SourceName;
MyLog.WriteEntry(errorMessage, EventLogEntryType.Error);
}
</script>
<%
EntrytoLog();
%>
日志表的结构是
LogID 自增序号
DbTable 操作表名
EventType 操作类型
OperateID 操作哪条记录
LogDetail 详细信息
RecordTime 时间
UserID 操作用户
详细信息里我是把所有字段的值写在里面。
再加上一些登录登出信息什么的。主要看你要用日志来干嘛了。
我这个只是要有这个功能,用其实不怎么用的。只要能显示有个记录就行了,这样做就足够了。
如不嫌这个简单我可以发代码上来。
作 者: hellomybeautiful (rReM)
等 级:
信 誉 值: 100
所属论坛: .NET技术 ASP.NET
问题点数: 100
回复次数: 0
发表时间: 2002-10-28 11:18:31
感谢您使用微软产品。
不知道您要记录什么样的信息。如果您要使用Windows提供的Log功能,您可以参阅下面的帖子:http://expert.csdn.net/expert/topic/1011/1011486.xml希望对您有所帮助。
-微软全球技术中心 -zgh
本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
表名 类型 说明
i_BroadCastID Int not 点播ID (PK)
i_CourseWareId Int not 课件ID
dt_BroadCastDate Date not 点播时间
i_MemberID Int not 点播人ID
nvc_Memo Nvarchar(255) 备注