Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Exclude a user from even log View modes: 
User avatar
Member
Member
Aon_Vlado - 11/6/2012 9:39:03 AM
   
Exclude a user from even log
We are using a third party monitoring service which log in to our site every 5 minutes to check if all financial data were pulled correctly from external database. This creates a huge event log which we do not need. I know that there is no way to exclude a user from crating an event log, but I would consider to alter code if necessary.

Where to implement this logic, please?

Thanks,
Vlado

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 11/6/2012 9:55:21 AM
   
RE:Exclude a user from even log
My suggestion would be to create a scheduled task to run every X number of minutes to delete those log records.

Here is some info on scheduled tasks and creating a custom code and registering the task. http://devnet.kentico.com/docs/devguide/index.html?scheduler_overview.htm

Here is some info on managing your event log: http://devnet.kentico.com/docs/7_0rc/devguide/index.html?event_log_api_examples_managing_log_events.htm

User avatar
Member
Member
Aon_Vlado - 11/13/2012 10:26:55 AM
   
RE:Exclude a user from even log
FroggEye, thank you for the tip.

There is no sample in documentation how to delete a log item so here is the snippet of the shceduled task for the others:
public string Execute(TaskInfo ti)
{
// Create new instance of event log provider
EventLogProvider eventLog = new EventLogProvider();
string[] splitUsers = ti.TaskData.Split(';');

foreach (string user in splitUsers)
{
// Get events matching the where condition
string where = "UserName = '" + user + "'";
DataSet events = eventLog.GetAllEvents(where, null);
if (!DataHelper.DataSourceIsEmpty(events))
{
int cnt = 0;
// Loop through the individual items
foreach (DataRow eventDr in events.Tables[0].Rows)
{
// Create the object from DataRow
EventLogInfo deleteEvent = new EventLogInfo(eventDr);
//Delete log
deleteEvent.Destroy();
eventLog.SetEventLogInfo(deleteEvent);
cnt++;
}
string detail = cnt.ToString() + " events of user '" + user + "' deleted from Event Log.";

// Logs the execution of the task in the event log.
EventLogProvider.LogInformation("DeleteUsers", "Execute", detail);
}
}
return null;
}

Add user names delimited by ';' to Task Data property of your Scheduled Task.

Vlado

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 11/14/2012 3:38:57 AM
   
RE:Exclude a user from even log
Hello Vlado,

Thank you for your code suggestion. I will notice our developers about it and maybe in the one of the future versions it will be available via API Examples (CMSSiteManager -> Support -> Api Examples).

However, I have to say thanks to both of you. FroggEye wrote the same advice as I would wrote.

Best regards,
Martin Danko

User avatar
Member
Member
chardi-marouane-hotmail - 5/25/2013 6:57:24 PM
   
RE:Exclude a user from even log
hello ,

i need to create a custom scheduled Task that sends an email containing all what happen in the event log every 24h.

would you help me please to create this Task.
I would really really appreciate that.

I followed the steps for creating a custom Scheduled Task and i get this error :
Error: [ClasHelper.GetClass]: App_Code class cannot be loaded because the OnGetCustomClass handler is not initialized.

please help to create this Task please .

Best Regards

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 5/26/2013 1:46:57 AM
   
RE:Exclude a user from even log
Hi,

The same issue is being solved in the this thread.

Best regards,
Juraj Ondrus