Print to DotNetNuke Event Log/Viewer

后端 未结 4 1722
盖世英雄少女心
盖世英雄少女心 2021-02-19 07:06

For debugging purposes, how can I print to the event log/viewer in DotNetNuke, using VB.NET or C#?

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-19 07:31

    using DotNetNuke.Common.Utilities;
    using DotNetNuke.Services.Log.EventLog;
    public static void DnnEventLogMsg(string msg)
    {
        EventLogController eventLog = new EventLogController();
        DotNetNuke.Services.Log.EventLog.LogInfo logInfo = new LogInfo();
        PortalSettings ps = PortalController.Instance.GetCurrentPortalSettings();
        UserInfo userInfo = UserController.Instance.GetCurrentUserInfo();
        logInfo.LogUserID = userInfo.UserID;
        logInfo.LogPortalID = ps.PortalId;
        logInfo.LogTypeKey = EventLogController.EventLogType.ADMIN_ALERT.ToString();
        logInfo.AddProperty("Atena3 Message", msg);
        eventLog.AddLog(logInfo);
    }
    

提交回复
热议问题