有人可能有一个示例来替换 DNN 模块中旧的错误日志记录吗?
我看过以下文章:
- https://dnncommunity.org/forums/aft/1527
- Has anyone implemented DotNetNuke.Abstractions.Portals.IPortalAliasInfo.HttpAlias in DNN version 9.9?
catch (Exception ex)
{
EventLogController logController = new EventLogController();
logController.AddLog("Problem Getting Product Description, Title, or Image URL.", ex.ToString(), EventLogController.EventLogType.ADMIN_ALERT);
}
您需要创建启动文件吗? 如果是的话,需要为每个模块创建一个启动文件还是放在根文件夹下?
最佳答案
这是一些适合我的代码:
using DotNetNuke.Abstractions;
using DotNetNuke.Abstractions.Logging;
using Microsoft.Extensions.DependencyInjection;
namespace myCompany.DNN.Modules.myModule {
private readonly IEventLogger _eventLogger;
public class myControl {
public myControl() { // this is the constructor of the class
_eventlogger = DependencyProvider.GetRequiredService<IEventLogger>();
}
}
protected override void someEvent(object sender, EventArgs e) {
try {
// some code
} catch(Exception ex) {
_eventLogger.AddLog("Problem Getting Product Description, Title, or Image URL.", ex.ToString(), EventLogController.EventLogType.ADMIN_ALERT);
}
}
}
还有这个article也可能有用...
关于error-handling - DNN 9.8 - EventLogController 已过时 - 有没有人有关于如何使用依赖注入(inject)方法来修复此错误的示例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71307883/