## Class template basic_event_log_backend

boost::log::sinks::basic_event_log_backend — An implementation of a logging sink backend that emits events into Windows NT event log.

## Synopsis

    // In header: <boost/log/sinks/event_log_backend.hpp>

    template<typename CharT>
    class basic_event_log_backend :
      public basic_sink_backend< synchronized_feeding >
    {
    public:
      // types
      typedef CharT                          char_type;                   // Character type.
      typedef std::basic_string< char_type > string_type;                 // String type.
      typedef std::vector< string_type >     insertion_list;              // Type of the composed insertions list.
      typedef unspecified                    event_type_mapper_type;      // Mapper type for the event type.
      typedef unspecified                    event_category_mapper_type;  // Mapper type for the event category.
      typedef unspecified                    event_composer_type;         // Event composer type.

      // construct/copy/destruct
      template<typename T>
        explicit basic_event_log_backend(std::basic_string< T > const &);
      explicit basic_event_log_backend(filesystem::path const &);
      template<typename... ArgsT>
        explicit basic_event_log_backend(ArgsT...const &);
      ~basic_event_log_backend();

      // public member functions
      void consume(record_view const &);
      void set_event_type_mapper(event_type_mapper_type const &);
      void set_event_category_mapper(event_category_mapper_type const &);
      void set_event_composer(event_composer_type const &);

      // public static functions
      static string_type get_default_log_name();
      static string_type get_default_source_name();
    };

## Description

The sink uses Windows NT 5 (Windows 2000) and later event log API to emit events to an event log. The sink acts as an event source. Unlike `basic_simple_event_log_backend`, this sink backend allows users to specify the custom event message file and supports mapping attribute values onto several insertion strings. Although it requires considerably more scaffolding than the simple backend, this allows to support localizable event descriptions.

Besides the file name of the module with event resources, the backend provides the following customizations:

- Remote server UNC address, log name and source name. These parameters have similar meaning to `basic_simple_event_log_backend`.

- Event type and category mappings. These are function object that allow to map attribute values to the according event parameters. One can use mappings in the `event_log` namespace.

- Event composer. This function object extracts event identifier and formats string insertions, that will be used by the API to compose the final event message text.

### `basic_event_log_backend` public construct/copy/destruct

1.     template<typename T>
         explicit basic_event_log_backend(std::basic_string< T > const & message_file_name);

   Constructor. Registers event source with name based on the application executable file name in the Application log. If such a registration is already present, it is not overridden.

2.     explicit basic_event_log_backend(filesystem::path const & message_file_name);

   Constructor. Registers event source with name based on the application executable file name in the Application log. If such a registration is already present, it is not overridden.

3.     template<typename... ArgsT>
         explicit basic_event_log_backend(ArgsT...const & args);

   Constructor. Registers event log source with the specified parameters. The following named parameters are supported:

   - `message_file` - Specifies the file name that contains resources that describe events and categories.

   - `target` - Specifies an UNC path to the remote server to which log records should be sent to. The local machine will be used to process log records, if not specified.

   - `log_name` - Specifies the log in which the source should be registered. The result of `get_default_log_name` is used, if the parameter is not specified.

   - `log_source` - Specifies the source name. The result of `get_default_source_name` is used, if the parameter is not specified.

   - `registration` - Specifies the event source registration mode in the Windows registry. Can have values of the `registration_mode` enum. Default value: `on_demand`.

   Parameters: |
   `args` | A set of named parameters.

4.     ~basic_event_log_backend();

   Destructor. Unregisters event source. The log source description is not removed from the Windows registry.

### `basic_event_log_backend` public member functions

1.     void consume(record_view const & rec);

   The method creates an event in the event log

   Parameters: |
   `rec` | Log record to consume

2.     void set_event_type_mapper(event_type_mapper_type const & mapper);

   The method installs the function object that maps application severity levels to WinAPI event types

3.     void set_event_category_mapper(event_category_mapper_type const & mapper);

   The method installs the function object that extracts event category from attribute values

4.     void set_event_composer(event_composer_type const & composer);

   The method installs the function object that extracts event identifier from the attributes and creates insertion strings that will replace placeholders in the event message.

### `basic_event_log_backend` public static functions

1.     static string_type get_default_log_name();

   Returns: | Default log name: Application

2.     static string_type get_default_source_name();

   Returns: | Default log source name that is based on the application executable file name and the sink name