Title: Only Log Specific Events
Last modified: September 10, 2020

---

# Only Log Specific Events

 *  Resolved [Alkorr](https://wordpress.org/support/users/alkorr/)
 * (@alkorr)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/only-log-specific-events/)
 * Hi! I just installed this plugin and it seems to work perfectly so far! I have
   a question though: I would like to only log a couple of events:
    -  SimpleLogger (mandatory, I guess)
       SimpleUserLogger SimpleMediaLogger SimplePostLogger
      SimpleCategoriesLogger Plugin_DuplicatePost
 * I checked the forum before posting and I found this thread: [https://wordpress.org/support/topic/i-dont-want-to-track-plugin-and-theme-updates-how-not-to-log-those/](https://wordpress.org/support/topic/i-dont-want-to-track-plugin-and-theme-updates-how-not-to-log-those/)
 * Unfortunately I don’t know if it’s possible to only log these specific events
   and how to add more events to the function. If someone can help me, that would
   be great! 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [Alkorr](https://wordpress.org/support/users/alkorr/)
 * (@alkorr)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/only-log-specific-events/#post-13393242)
 * Hi, me again! I checked your github and I’ve seen this code, which in fact does
   the opposite I’m looking for:
 *     ```
       // Do not log some post types, for example pages and attachments in this case
       add_filter('simple_history/log/do_log', function ($do_log = null, $level = null, $message = null, $context = null, $logger = null) {
   
           $post_types_to_not_log = array(
               'page',
               'attachment',
           );
   
           if (( isset($logger->slug) && ($logger->slug === 'SimplePostLogger' || $logger->slug === 'SimpleMediaLogger') ) && ( isset($context['post_type']) && in_array($context['post_type'], $post_types_to_not_log) )) {
               $do_log = false;
           }
   
           return $do_log;
       }, 10, 5);
       ```
   
 * I can’t list all the events I want to be logged because I only want to log 5 
   events.
 * Thanks a lot! 🙂
 *  Plugin Author [Pär Thernström](https://wordpress.org/support/users/eskapism/)
 * (@eskapism)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/only-log-specific-events/#post-13404846)
 * Would this work perhaps?
 *     ```
       /**
        * Load only the loggers that are specified in the $do_log_us array.
        */
       add_filter(
           'simple_history/logger/load_logger',
           function ($load_logger, $logger_basename) {
               $load_logger = false;
   
               $do_log_us = [
                   'SimpleUserLogger',
                   'SimpleMediaLogger',
                   'SimplePostLogger',
                   'SimpleCategoriesLogger',
                   'Plugin_DuplicatePost',
                   'SimpleLogger',
               ];
   
               if (in_array($logger_basename, $do_log_us)) {
                   $load_logger = true;
               }
   
               return $load_logger;
           },
           10,
           2
       );
       ```
   
 *  Thread Starter [Alkorr](https://wordpress.org/support/users/alkorr/)
 * (@alkorr)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/only-log-specific-events/#post-13405757)
 * I guess it does, thank you so much! 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Only Log Specific Events’ is closed to new replies.

 * ![](https://ps.w.org/simple-history/assets/icon.svg?rev=3225008)
 * [Simple History – Track, Log, and Audit WordPress Changes](https://wordpress.org/plugins/simple-history/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/simple-history/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/simple-history/)
 * [Active Topics](https://wordpress.org/support/plugin/simple-history/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/simple-history/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/simple-history/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Alkorr](https://wordpress.org/support/users/alkorr/)
 * Last activity: [5 years, 8 months ago](https://wordpress.org/support/topic/only-log-specific-events/#post-13405757)
 * Status: resolved