Event Logs

Helpdesk PING asked on January 29, 2019 15:44

I have event logs size configured to 500000. We have some custom log events that we log for returns. When I search for them in the event log I only see the last two days for returns. When I search for the oldest log in the event log, the event logs go back to 11/16/18. Why are the custom log events not showing that far back. Is there a setting somewhere for that?

I am using the following calls to log these events.

EventLogProvider.LogInformation(EventSource, "START_RETURN_IMPORT"); EventLogProvider.LogInformation(EventSource, "RETURN_ADDED", logDescription); EventLogProvider.LogInformation(EventSource, "INVALID_ORDER_ID", $"Invalid Order Id: {orderId}"); EventLogProvider.LogInformation(EventSource, "SKU_NUMBER_NOT_FOUND", logDescription);

Those are just a few examples.

Thanks, Eric

Recent Answers


David te Kloese answered on January 29, 2019 15:59 (last edited on January 29, 2019 16:00)

The number you set in the Settings module is the number of records you want to log per type.

If you set it to 1000 your instance will log

  • 1000 global events
  • 1000 events for EACH site in that instance
    • So if you have 3 sites 3x 1000 with it's own cleanup

So it could be that you are looking for a global event which is over 1000 records old, but the site specific events dates back further because it doesn't log that much.

If you have custom code with very specific log records you like to keep, you might look into saving it in a different place that doesn't get automatically cleaned. Something like a Custom Table or Custom Class.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on January 29, 2019 16:01

If you're not finding events for those codes, then they aren't being triggered to create an event. If you want or need to keep track of these logs, I'd suggest creating a custom table or module and log them there so you don't have to deal with the event log automatically cleaning them up. I'd also suggest when creating your custom table records, to turn off event logging so it's only writing the record to the custom table and not both the custom table and writing an event for creating the custom table record.

You can do so by using this code:

using (var ac = new CMSActionContext(){
    LogEvents = false,
    LogSynchronization = false,
    LogIntegration = false,
    LogWebFarmTasks = false
})
{
   // code here to insert custom table record
} 
1 votesVote for this answer Mark as a Correct answer

Helpdesk PING answered on January 29, 2019 16:27

I am confused as to why it would clean up those logs so quickly. We get about 3-5 log entries a week for returns but I can only see the last two days worth. I get the logs cleanup but why so quickly. Is there something I am missing.

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on January 29, 2019 16:39

Setting - Event log size

Limits the maximum number of events stored in the Event log.

  • When exceeded by 10% (or a different percentage set by means of the CMSLogKeepPercent web.config key), the percentage of the oldest events is deleted from the log in a batch.
  • Old events that exceed the limit are not deleted immediately, but only after a new event is logged. Applies separately to site-specific events for each site and global events. For example, if you set the limit to 100, the log may contain 110 site-specific events for each site in the system, and 110 global events.

if you have set the setting to 500000 and didn't change the percent key it would mean you get around 500000+50000 records a day? which seems quite a lot...

If you look at the settings is the value for the site specific log setting set to inherit? Image Text

0 votesVote for this answer Mark as a Correct answer

Helpdesk PING answered on January 29, 2019 16:52

Exactly. So why are my logs not appearing. I do not receive enough logs in a day to have the log entries I mentioned above to roll off after 48 hours. Is there something I am missing?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.