DotNetNuke 和错误日志记录
DotNetNuke 是否提供任何内置的错误日志框架?我的客户正在使用 DotNetNuke,但我没有看到全局错误日志记录框架。我看到下面的类有一些 try/catch 使用它们。
namespace DotNetNuke.Services.Exceptions
{
[StandardModule]
public sealed class Exceptions
{
public static ExceptionInfo GetExceptionInfo(Exception e);
public static void LogException(Exception exc);
public static void LogException(ModuleLoadException exc);
public static void LogException(PageLoadException exc);
public static void LogException(SchedulerException exc);
public static void LogException(SecurityException exc);
public static void LogSearchException(SearchException exc);
public static void ProcessModuleLoadException(Control ctrl, Exception exc);
public static void ProcessModuleLoadException(PortalModuleBase objPortalModuleBase, Exception exc);
public static void ProcessModuleLoadException(Control ctrl, Exception exc, bool DisplayErrorMessage);
public static void ProcessModuleLoadException(PortalModuleBase objPortalModuleBase, Exception exc, bool DisplayErrorMessage);
public static void ProcessModuleLoadException(string FriendlyMessage, Control ctrl, Exception exc);
public static void ProcessModuleLoadException(string FriendlyMessage, Control ctrl, Exception exc, bool DisplayErrorMessage);
public static void ProcessModuleLoadException(string FriendlyMessage, PortalModuleBase objPortalModuleBase, Exception exc, bool DisplayErrorMessage);
public static void ProcessPageLoadException(Exception exc);
public static void ProcessPageLoadException(Exception exc, string URL);
public static void ProcessSchedulerException(Exception exc);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Log4Net 可用,但大多数模块使用 DNN 中的自定义异常类,它将在 EventLog 表中存储“事件”,您可以从管理/事件查看器页面访问“事件”(包括错误)的报告。
通常在模块中您会执行如下操作。
Log4Net is available, but most modules use the custom exceptions class within DNN which will store "events" in the EventLog table, you can access the reports for "events" including errors, from the Admin/Event Viewer page.
Typically within a module you would do something like the following.
DNN 包括 log4net,请参阅此 wiki 文章: http://dnnsoftware.com/Wiki/Page/ log4net-In-DotNetNuke
DNN includes log4net, see this wiki article: http://dnnsoftware.com/Wiki/Page/log4net-In-DotNetNuke
自从有关此问题的原始帖子发布以来已经很长一段时间了,在为自己做了一些研究之后,我相信我找到了比公认的答案更好、更新的资源。以下内容包含有关如何设置 Log4Net 并将其集成到模块中的更多信息,http://www.dnnsoftware.com/community-blog/cid/141723/Using-log4net-with-DotNetNuke。
看来使用 Log4Net 方法的优点之一是能够配置日志记录级别,以便更轻松地调查和调试应用程序。在环境之间移动应用程序时,这尤其有用。我在调试服务器上的应用程序时使用了它,在该服务器上我无法附加到进程并中断应用程序进行调试。我调高日志记录级别并使用日志中的信息。这可能是一种痛苦的调试方式,但当您陷入困境时却非常有帮助。
在 DNN 7 中,此处提到的 DnnLog 类已被弃用,因此可能应该探索替代方案。
看起来自定义异常类适用于在所有情况下都需要记录的异常。我发现这篇稍旧的文章可能仍然相关,如果需要记录自定义信息,http://www.ifinity.com.au/Blog/EntryId/114/Creating-Exception-Logging-with-DotNetNuke。有些课程需要更新,但整体技术看起来不错,并且更符合克里斯上面的建议。
通过稍加调整,此示例可用于实现可配置的日志记录级别。
It has been a long time since the original post about this and after doing some research for myself I believe I found a better and more recent resource than the accepted answer. The following includes a little more information about how to get Log4Net set up and integrated into your modules, http://www.dnnsoftware.com/community-blog/cid/141723/Using-log4net-with-DotNetNuke.
It appears that one advantage to using the Log4Net approach is the ability to configure the logging level so applications can be more easily investigated and debugged. This can be especially helpful when moving applications between environments. I used this while debugging an application on a server where I can't attach to the process and interupt the application to debug. I turn up the logging level and work with the info in the log. This can be painful a painful way to debug, but really helpful when you are stuck.
In DNN 7 the DnnLog class mentioned here is depreciated so alternatives should probably be explored.
It looks like the custom exceptions class is intended for exceptions that need to be logged in all cases. I found this slightly older article that is likely still relevant if there is the need to log custom information, http://www.ifinity.com.au/Blog/EntryId/114/Creating-Exception-Logging-with-DotNetNuke. Some classes will need to be updated but the overall technique looked good and goes more in line with Chris's suggestion above.
With a little tweaking this example could be used to implement a configurable logging level.
我的理解是,您有以下选项:
My understanding is that you have the following options: