Loupe Agent supports multiple ways of providing it configuration data.  In particular, it supports both configuration files (e.g. app.config and web.config) and configuration via code in your application (for example the Log.Initializing event). With multiple ways of providing configuration, what happens when configuration options are provided through multiple paths at the same time?

Order of Configuration

Loupe follows a deterministic pattern of applying configuration data:

  1. Load Default Configuration: The configuration objects are created using all default values as listed in the documentation.
  2. Apply Configuration Files: Each configuration line that can be parsed from the config file overrides the default for each value it specifies.
  3. Coded Configuration: The merged configuration is presented to your application code during the Log.Initializing event.  You can modify it, overriding the configuration.
  4. Configuration Normalization: The configuration objects are checked for out of range or nonsensical values which are replaced with reasonable defaults (for example specifying a negative maximum size causes it to revert to the default maximum size).
This pattern means that coded configuration overrides file configuration.  If you specify a configuration value in code it can't be modified in the configuration file.
Configuration isn't normalized until the entire process is configured so a missing value in the configuration file (such as enabling server communication but not adequately defining the server) will be preserved until the very end of the process.