DNN 9.8 - EventLogController 已过时 - 有没有人有关于如何使用依赖注入方法来修复此错误的示例?

发布于 2025-01-11 04:24:58 字数 918 浏览 0 评论 0原文

有人可能有一个示例来替换 DNN 模块中旧的错误日志记录吗?

我看过以下文章:

  1. https://dnncommunity.org/forums/aft/1527
  2. <一href="https://stackoverflow.com/questions/66790246/has-anyone-implemented-dotnetnuke-abstractions-portals-iportalaliasinfo-httpalia">有人在 DNN 版本 9.9 中实现了 DotNetNuke.Abstractions.Portals.IPortalAliasInfo.HttpAlias 吗?< /a>

我目前收到以下错误: 输入图片此处描述

catch (Exception ex)
    {
      EventLogController logController = new EventLogController();
      logController.AddLog("Problem Getting Product Description, Title, or Image URL.", ex.ToString(), EventLogController.EventLogType.ADMIN_ALERT);
    }

您需要创建启动文件吗? 如果是的话,是否需要为每个模块创建一个启动文件或者将其放在根文件夹中?

Does anyone perhaps have an example to replace the old Error logging in DNN module?

I have looked at the following articles:

  1. https://dnncommunity.org/forums/aft/1527
  2. Has anyone implemented DotNetNuke.Abstractions.Portals.IPortalAliasInfo.HttpAlias in DNN version 9.9?

I currently get the following error:
enter image description here

catch (Exception ex)
    {
      EventLogController logController = new EventLogController();
      logController.AddLog("Problem Getting Product Description, Title, or Image URL.", ex.ToString(), EventLogController.EventLogType.ADMIN_ALERT);
    }

Do you need to create a startup file?
If so, do you need to create a startup file for each module or put it in the root folder?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灼疼热情 2025-01-18 04:24:58

这是一些适合我的代码:

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);
      }
   }
}

这篇文章 也可能有用...

Here is some code that works for me:

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);
      }
   }
}

And this article could be useful, too...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文