Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

Affordable ASP.NET Hosting Service
  Ads  
Aspose - The .NET & Java component publisher
 


  Sponsors  

Meet Our Sponsors

Salaro -- Skins and more
OnyakTech
CrystalTech Web Hosting™
Webhost4life, specialists in DNN hosting
Mad Development is a full service interactive agency focusing on the merge of design, technology, e-commerce, and affiliate marketing by providing total website solutions.
SteadyRain
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Extend It! ( Pr...  How to add custom Event Log Type?
Previous Previous
 
Next Next
New Post 5/11/2006 1:22 AM
User is offline Michael Freidgeim
89 posts
geekswithblogs.net/mnf/
10th Ranked


How to add custom Event Log Type? 

I want to create custom Event Log Type for my module and write my messages to EventLogTypes table and then view them using DNN Log Viewer.
Is any documentation/tips, how to do it, available?

Regards,

Michael Freidgeim
Blog: http://geekswithblogs.net/mnf/


Michael Freidgeim http://geekswithblogs.net/mnf
 
New Post 5/15/2006 6:31 AM
User is offline cathal connolly
2757 posts
www.cathal.co.uk
5th Ranked










Re: How to add custom Event Log Type? 

We haven't produced any documentation  as far as I know (though the DNN book does cover the event/exception's API's so that's a good resource to start with). I've added a new exception type to the next release, SecurityException, so that it can be utilised in a number of locations, it's not an easy task, and one best dealt with in the upgrade.vb at present, until the next release when the eventing model will make items like this a bit easier.

Anyway, the code I used is as follows:

1. adding the exception type in upgrade.vb (I created an xml file [SecurityExceptionTemplate.xml.resources] with the details, both the definition, and the event schedule details - you can look at the other .xml.resources file to work out the necessary details)

                        'add new SecurityException
                        Dim objSecLogController As New Log.EventLog.LogController
                        Dim xmlSecDoc As New XmlDocument
                        Dim xmlSecConfigFile As String = Common.Globals.HostMapPath + "Logs\LogConfig\SecurityExceptionTemplate.xml.resources"
                        Try
                            xmlSecDoc.Load(xmlSecConfigFile)
                        Catch exc As FileNotFoundException
                            '  xmlConfigFile = Common.Globals.HostMapPath + "Logs\LogConfig\LogConfigTemplate.xml.resources"
                            ' xmlDoc.Load(xmlConfigFile)
                        End Try
                        Dim LogType As XmlNodeList = xmlSecDoc.SelectNodes("/LogConfig/LogTypes/LogType")
                        Dim LogTypeInfo As XmlNode
                        For Each LogTypeInfo In LogType
                            Dim objLogTypeInfo As New Log.EventLog.LogTypeInfo
                            objLogTypeInfo.LogTypeKey = LogTypeInfo.Attributes("LogTypeKey").Value
                            objLogTypeInfo.LogTypeFriendlyName = LogTypeInfo.Attributes("LogTypeFriendlyName").Value
                            objLogTypeInfo.LogTypeDescription = LogTypeInfo.Attributes("LogTypeDescription").Value
                            objLogTypeInfo.LogTypeCSSClass = LogTypeInfo.Attributes("LogTypeCSSClass").Value
                            objLogTypeInfo.LogTypeOwner = LogTypeInfo.Attributes("LogTypeOwner").Value
                            objSecLogController.AddLogType(objLogTypeInfo)
                        Next

                        Dim LogTypeConfig As XmlNodeList = xmlSecDoc.SelectNodes("/LogConfig/LogTypeConfig")
                        Dim LogTypeConfigInfo As XmlNode
                        For Each LogTypeConfigInfo In LogTypeConfig
                            Dim objLogTypeConfig As New Log.EventLog.LogTypeConfigInfo
                            objLogTypeConfig.EmailNotificationIsActive = Convert.ToBoolean(IIf(LogTypeConfigInfo.Attributes("EmailNotificationStatus").Value = "On", True, False))
                            objLogTypeConfig.KeepMostRecent = LogTypeConfigInfo.Attributes("KeepMostRecent").Value
                            objLogTypeConfig.LoggingIsActive = Convert.ToBoolean(IIf(LogTypeConfigInfo.Attributes("LoggingStatus").Value = "On", True, False))
                            objLogTypeConfig.LogTypeKey = LogTypeConfigInfo.Attributes("LogTypeKey").Value
                            objLogTypeConfig.LogTypePortalID = LogTypeConfigInfo.Attributes("LogTypePortalID").Value
                            objLogTypeConfig.MailFromAddress = LogTypeConfigInfo.Attributes("MailFromAddress").Value
                            objLogTypeConfig.MailToAddress = LogTypeConfigInfo.Attributes("MailToAddress").Value
                            objLogTypeConfig.NotificationThreshold = Convert.ToInt32(LogTypeConfigInfo.Attributes("NotificationThreshold").Value)
                            objLogTypeConfig.NotificationThresholdTime = Convert.ToInt32(LogTypeConfigInfo.Attributes("NotificationThresholdTime").Value)
                            objLogTypeConfig.NotificationThresholdTimeType = CType(LogTypeConfigInfo.Attributes("NotificationThresholdTimeType").Value, Services.Log.EventLog.LogTypeConfigInfo.NotificationThresholdTimeTypes)
                            objSecLogController.AddLogTypeConfigInfo(objLogTypeConfig)
                        Next

2. Create a new event type - look @ components\providers\logging\event logging\EventLogController.vb, you'll need to edit the ENUM and add your new EventLogType.

3. edit admin\logging\logviewer.ascx if necessary with a unique colour for your new event.

Alternatively,  piggyback on one of the existing events- most support passing a message, as well as variours serialised data formats, so you could craft the message to contain your module name at the start.

Cathal

 
New Post 5/28/2006 11:24 PM
User is offline Michael Freidgeim
89 posts
geekswithblogs.net/mnf/
10th Ranked


Re: How to add custom Event Log Type? 

Cathal,

Thank you for your informative reply. It pointed me to the right direction.
1. I've added my custom event types just by inserting extra records to dnn_EventLogTypes.

2.Also adding  new EventLogType to EventLogController.EventLogType is OPTIONAL. Even not all core event types are listed in ENUM. I didn't want to modify core class for each custom event type, that any developer can create.
Fortunately, there are couple EventLogController.AddLog overloads that expect LogTypeKey As String , which  make possible to avoid modifiing EventLogController.EventLogType enum.

3. I also beleive that it is possible to add extra color classes for new event by adding the new css classes to global portal.css whithout modifiing core admin\logging\logviewer.ascx. (I haven't tried this,because current css classes are sufficient for my purposes).  

 

 


Michael Freidgeim http://geekswithblogs.net/mnf
 
Previous Previous
 
Next Next
  Forum  General DotNetN...  Extend It! ( Pr...  How to add custom Event Log Type?
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, please observe the following posting guidelines:

1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


DotNetNuke® in Sweden
All service of DotNetNuke® in Sweden.
Olsmar Konsult
Verndale - Web Development, Support, Hosting
Since 1998, Verndale has helped hundreds of emerging and midsize businesses maximize the value and reach of their web assets with a comprehensive offering of strategy, design, development, search marketing and support services.
www.verndale.com
Overlook Technology
Website Development, DotNetNuke Consulting, Module Development, Portal Management
OverlookTechnology.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP