Print to DotNetNuke Event Log/Viewer

后端 未结 4 1736
盖世英雄少女心
盖世英雄少女心 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:40

    From http://www.ventrian.com/Resources/Articles/tabid/213/articleType/ArticleView/articleId/330/Logging-to-the-EventLog.aspx (just the relevant part of the article):

    Using the event log in code is quite simple, the code is as follows:-

    First, create an instance of the EventLogViewer...

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

    Next, log the event you wish to trap...

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

    Now, when this code is run, the event log entry should appear in admin -> log viewer! You can customise these type of events, whether they be admin, host, item updated, etc.

提交回复
热议问题