打印到DotNetNuke事件日志/查看器

时间:2010-01-11 14:19:16

标签: c# vb.net dotnetnuke

出于调试目的,如何使用VB.NET或C#打印到DotNetNuke中的事件日志/查看器?

4 个答案:

答案 0 :(得分:23)

来自http://www.ventrian.com/Resources/Articles/tabid/213/articleType/ArticleView/articleId/330/Logging-to-the-EventLog.aspx(只是文章的相关部分):

  

在代码中使用事件日志是完全正确的   简单,代码如下: -

     

首先,创建一个实例   EventLogViewer ...

Dim objEventLog As New DotNetNuke.Services.Log.EventLog.EventLogController
     

接下来,记录您想要的事件   陷阱...

objEventLog.AddLog("Sample Message",
    "Something Interesting Happened!",
    PortalSettings,
    -1,
    DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.ADMIN_ALERT)
     

现在,当运行此代码时,事件   日志条目应出现在admin - >   日志查看器!您可以自定义这些   事件的类型,无论他们是管理员,   主持人,项目更新等。

答案 1 :(得分:8)

答案 2 :(得分:5)

这是C#版本

using DotNetNuke.Common.Utilities;
using DotNetNuke.Services.Log.EventLog;

EventLogController eventLog = new EventLogController();
DotNetNuke.Services.Log.EventLog.LogInfo logInfo = new LogInfo();
logInfo.LogUserID = UserId;
logInfo.LogPortalID = PortalSettings.PortalId;
logInfo.LogTypeKey=EventLogController.EventLogType.ADMIN_ALERT.ToString();
logInfo.AddProperty("KeyWord=", txtSearch.Text.Trim());
logInfo.AddProperty("KeyWordLike=", myParams);
eventLog.AddLog(logInfo);

答案 3 :(得分:0)

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