编写应用程序日志的例外 [英] Writing Exceptions to the Application Log

查看:55
本文介绍了编写应用程序日志的例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好


我正试图找到使用Vb.Net向应用程序写入例外的正确方法

日志。


我已经做了相当多的Google,虽然这有很多提及

,这显然是正确的前进方式没有人提供解决方案
如何实际完成。


我收集的代码如下:


试试

''我的代码在这里

Catch ex As Exception

My.Log.WriteException(ex)

结束尝试


会将异常写入监听器但是没有提到如何在Web App上设置

监听器以及如何配置它来写入

应用程序日志(安全权限等)


大量的在线信息表明注册表被黑客攻击,但这看起来并不像是b $ b appropiatte。


PS。我确实觉得具有讽刺意味的是,如果我没有抓住异常,它会默认写入

到日志。


感谢您的帮助。


Martyn


-

问候


Martyn Fewtrell

Hi there

I''m trying to find the correct way to write exceptions to the Application
log using Vb.Net.

I''ve done a fair bit of Googleing and although this gets plenty of mentions
and that this is apparently the correct way forward nobody offers a solution
as to how it is actually done.

I gather that code like:

Try
''my code goes here
Catch ex As Exception
My.Log.WriteException(ex)
End Try

Will write the exception to a listener but there is no mention of how a
listener is set up on a web App and how this is configured to write to the
Application Log (Security permissions etc)

Plenty of the on line info suggest a Registry hack but this doesnt seem
appropiatte.

PS. I do find it ironic that if i dont catch the exception it gets written
to the log by default.

Thanks for your help.

Martyn


--
Regards

Martyn Fewtrell

推荐答案

不要费心去写应用程序日志。


Peter Bromberg概述了一个更好的在本文中记录异常的方法:

http: //www.eggheadcafe.com/articles/20030816.asp

阅读文章......并下载他的样本代码:
http://www.eggheadcafe.com/articles/20030816.zip



Juan T. Llibre,asp.net MVP

aspnetfaq.com: http://www.aspnetfaq.com /

asp.net faq: http:/ /asp.net.do/faq/

foros de asp.net,en espa?ol: http://asp.net.do/foros/

=============== ====================

" Martyn Fewtrell" < mf ******* @ newsgroup.nospamwrote in message

news:69 *********************** *********** @ microsof t.com ...
Don''t bother writing to the Application log.

Peter Bromberg outlines a much better way to log exceptions in this article :

http://www.eggheadcafe.com/articles/20030816.asp

Read the article...and download his sampl code at :
http://www.eggheadcafe.com/articles/20030816.zip


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
===================================
"Martyn Fewtrell" <mf*******@newsgroup.nospamwrote in message
news:69**********************************@microsof t.com...

你好


我'我试图找到使用Vb.Net写应用程序

日志的例外的正确方法。


我做了很多谷歌,虽然这有很多提及

,这显然是正确的前进方式没有人提供解决方案

如何实际完成。


我收集的代码如下:


试试

''我的代码就在这里

Catch ex作为例外

My.Log.WriteException(ex)

结束尝试


将异常写入监听器但是有没有提到如何在Web应用程序上设置

监听器以及如何将其配置为写入

应用程序日志(安全权限等)


大量的在线信息建议一个注册表黑客,但这似乎不适用
appropiatte。


PS。我确实觉得具有讽刺意味的是,如果我没有抓住异常,它会默认写入

到日志。


感谢您的帮助。


Martyn


-

问候


Martyn Fewtrell
Hi there

I''m trying to find the correct way to write exceptions to the Application
log using Vb.Net.

I''ve done a fair bit of Googleing and although this gets plenty of mentions
and that this is apparently the correct way forward nobody offers a solution
as to how it is actually done.

I gather that code like:

Try
''my code goes here
Catch ex As Exception
My.Log.WriteException(ex)
End Try

Will write the exception to a listener but there is no mention of how a
listener is set up on a web App and how this is configured to write to the
Application Log (Security permissions etc)

Plenty of the on line info suggest a Registry hack but this doesnt seem
appropiatte.

PS. I do find it ironic that if i dont catch the exception it gets written
to the log by default.

Thanks for your help.

Martyn


--
Regards

Martyn Fewtrell



感谢Juan的提及,实际上我有更多的Generic

实现在这里:

http://www.eggheadcafe .com / articles / 20060531.asp


但是,如果你真的想写信息日志,请看看

System.Diagnostics名称空间。有静态的方法。

彼得


-

联合创始人,Eggheadcafe.com开发者门户网站:
http://www.eggheadcafe.com

UnBlog:
http://petesbloggerama.blogspot.com



" Martyn Fewtrell"写道:
Thanks to Juan for the mention, actually I have an even more "Generic"
implementation of that here:

http://www.eggheadcafe.com/articles/20060531.asp

However, if you really want to write to the Event Log, take a look at the
System.Diagnostics Namepace. There are static methods there for this.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Martyn Fewtrell" wrote:

你好


我正试图找到为应用程序写例外的正确方法/>
使用Vb.Net登录。


我已经做了很多Google,虽然这有很多提及

和这显然是正确的前进方式没有人提供解决方案

如何实际完成。


我收集的代码如下:


尝试

''我的代码在这里

Catch ex As Exception

My.Log.WriteException(ex )

结束尝试


将异常写入监听器但是没有提到如何设置

监听器在网络应用程序和如何配置写入

应用程序日志(安全权限等)


大量的在线信息表明注册表黑客但这看起来并不适合

appropiatte。


PS。我确实觉得具有讽刺意味的是,如果我没有抓住异常,它会默认写入

到日志。


感谢您的帮助。


Martyn


-

问候


Martyn Fewtrell
Hi there

I''m trying to find the correct way to write exceptions to the Application
log using Vb.Net.

I''ve done a fair bit of Googleing and although this gets plenty of mentions
and that this is apparently the correct way forward nobody offers a solution
as to how it is actually done.

I gather that code like:

Try
''my code goes here
Catch ex As Exception
My.Log.WriteException(ex)
End Try

Will write the exception to a listener but there is no mention of how a
listener is set up on a web App and how this is configured to write to the
Application Log (Security permissions etc)

Plenty of the on line info suggest a Registry hack but this doesnt seem
appropiatte.

PS. I do find it ironic that if i dont catch the exception it gets written
to the log by default.

Thanks for your help.

Martyn


--
Regards

Martyn Fewtrell


啊......

感谢您的更新,Peter。


Juan T. Llibre,asp.net MVP

aspnetfaq.com: http: //www.aspnetfaq.com/

asp.net faq: http://asp.net.do/faq/

foros de asp.net,en espa?ol: http://asp.net.do/foros/

======== ===========================

" Peter Bromberg [C#MVP]" < pb ******* @ yahoo.nospammin.com写信息

新闻:6F ********************* ************* @ microsof t.com ...
Ahh...
Thanks for that update, Peter.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
===================================
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.comwrote in message
news:6F**********************************@microsof t.com...

感谢Juan的提及,实际上我还有更多Generic

在此执行:

http://www.eggheadcafe.com/articles/20060531.asp


但是,如果你真的想写入事件日志,看看

System.Diagnostics Namepace。有静态的方法。

彼得


-

联合创始人,Eggheadcafe.com开发者门户网站:
http://www.eggheadcafe.com

UnBlog:
http://petesbloggerama.blogspot.com






" Martyn Fewtrell"写道:
"Martyn Fewtrell" wrote:

>您好

我正在努力找到为应用程序编写例外的正确方法
使用Vb.Net进行日志记录。

我已经做了很多Google,虽然这有很多提及,但这显然是正确的前进方式,没有人提供解决方案
我收集的代码如下:

尝试
''我的代码就在这里
Catch ex As异常
My.Log.WriteException(ex)
结束尝试

将异常写入监听器但是没有提到如何设置
监听器在Web应用程序上以及如何将其配置为写入
应用程序日志(安全权限等)

大量的在线信息表明注册表遭到黑客入侵,但这似乎不是什么
appropiatte。

PS。我觉得具有讽刺意味的是,如果我没有抓住异常,它会默认写入日志。

感谢您的帮助。

Martyn
>Hi there

I''m trying to find the correct way to write exceptions to the Application
log using Vb.Net.

I''ve done a fair bit of Googleing and although this gets plenty of mentions
and that this is apparently the correct way forward nobody offers a solution
as to how it is actually done.

I gather that code like:

Try
''my code goes here
Catch ex As Exception
My.Log.WriteException(ex)
End Try

Will write the exception to a listener but there is no mention of how a
listener is set up on a web App and how this is configured to write to the
Application Log (Security permissions etc)

Plenty of the on line info suggest a Registry hack but this doesnt seem
appropiatte.

PS. I do find it ironic that if i dont catch the exception it gets written
to the log by default.

Thanks for your help.

Martyn



这篇关于编写应用程序日志的例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆