Here is some hacked together code that implemented this… Check out the sexy aggregate function at the bottom… :)
DotNetNuke.Services.Log.EventLog.EventLogController lc = new DotNetNuke.Services.Log.EventLog.EventLogController();
// Check if the logtype exists.
List
if ( !logs.Any(x => x.LogTypeKey == "IPVideo_Links") )
{
// If Not, create the logtype.
LogTypeInfo lt = new LogTypeInfo();
lt.LogTypeCSSClass = "IPVideo_Links";
lt.LogTypeDescription = "Logging the IPVideo Links Module";
lt.LogTypeFriendlyName = "IPVideo Links";
lt.LogTypeKey = "IPVideo_Links";
lt.LogTypeOwner = "DotNetNuke.Logging.EventLogType";
lc.AddLogType(lt);
}
// Add a log entry.
lc.AddLog(new LogProperties{
new LogDetailInfo("Property1", "Some Value 1"),
new LogDetailInfo("Property2", "Some Value 2"),
new LogDetailInfo("TimeSubmitted", DateTime.Now.ToString())
},
this.PortalSettings,
this.UserId,
"IPVideo_Links", /* Should probably make this a enum value */
true);
// Retrieve the events for the log.
int total = 0;
List
// Get the events properties.
// I know you like my sexy use of Aggregate, admit it, its sexy.
string props = details.Aggregate
(result, logInfo) =>
String.Format("{0}{1}: {2}\n", result, logInfo.PropertyName, logInfo.PropertyValue));
// Show the properties.
txtDetails.Text = "Got the details\n" + props;
Here are some links I found useful when coming up with this code.
DNN Core API - Logging (pdf)
MSDN Aggregate Documentation