'DNN 9.8 - EventLogController is obsolete - Does anyone have an example on how to use the Dependency Injection method to fix this error?

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?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source