是否可以在不使用企业库的情况下创建自己的日志配置 [英] Is it possible to create a own loggingconfiguration like enterprise library without using it
问题描述
我想在不使用企业库的情况下创建自己的日志记录配置。我想在c#asp.net web项目的catch块中创建抛出错误的日志配置。
我尝试过:
我已经创建了自己的错误日志文件同样我们可以这样做我只是要求
是的,可以做这样的事情。
但是在你开始之前我会看看其他许多产品,比如
1. NLog
2. Log4Net
3. ELMAH
在开始创建自己的需求之前,看看它们是否符合您的需求。
引用:I想要在不使用企业库的情况下创建自己的日志记录配置我想在c#asp.net web项目的catch块中创建抛出错误的日志配置。
你确定可以创建自己的自定义日志记录。但是我建议你捕获特定类型的异常,只有在有意义时才能捕获。一个好的经验法则是,您应该只捕获可以正确处理自己的异常。如果你不能完全处理异常,那么你应该让它冒泡到可以的人身上。
我建议你给这篇文章读一读:C#异常处理最佳实践:查找&创建自定义例外 [ ^ ]
I want to create a own logging configuration without using enterprise library. I would like to create the logging configuration of throwing error in the catch block of c# asp.net web project.
What I have tried:
I already created error log file by own likewise can we do it or not i am just asking
Yes it is possible to do such a thing.
But before you start I would look at the many other products available such as
1. NLog
2. Log4Net
3. ELMAH
to see if they meet your needs before you start to create your own.
Quote:I want to create a own logging configuration without using enterprise library. I would like to create the logging configuration of throwing error in the catch block of c# asp.net web project.
You sure can create your own custom logging. However I recommend you to catch specific type of exceptions and only do a catch when it makes sense. A good rule of thumb is that you should only catch exceptions that you can properly deal with yourself. If you cannot handle the exception completely then you should let it bubble up to someone who can.
I would suggest you to give this article a read: C# Exception Handling Best Practices: Find & Create Custom Exceptions[^]
这篇关于是否可以在不使用企业库的情况下创建自己的日志配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!