Skip to content

Configuration

The bundle is configured under a single monitor tree, conventionally in config/packages/monitor.yaml. Every value maps directly onto the monitor-php core types the bundle wires for you.

Full reference

yaml
# config/packages/monitor.yaml
monitor:
    enabled: true
    url: '%env(MONITOR_URL)%'
    key: '%env(MONITOR_KEY)%'
    timeout: 3
    release: '%env(default::MONITOR_RELEASE)%'
    trace_limit: 0    # 0 = full trace (default); a positive value trims
    code_snippets: true    # source lines around application frames; false sends file and line only
    environments: []
    scrub: ['password', 'password_confirmation', 'passphrase', 'token', 'signature', 'secret', 'authorization', 'cookie', 'referer', 'referrer', 'api_key']
    redact: ['email', 'iban', 'nir', 'card', 'phone']
    redact_custom: {}   # your own shapes, as label: PCRE pattern
    logs:
        enabled: false
        level: warning
        max_batch: 200

Options

KeyTypeDefaultDescription
enabledbooltrueMaster switch. The services are always defined, and false acts at runtime: nothing is captured and nothing is sent. Defining them either way is what lets config/packages/dev/monitor.yaml set enabled: false without a monolog.yaml referencing monitor.log_handler failing to compile.
urlstringnullBase URL of your Quiet Guard server. Endpoint paths are appended to it; a trailing slash is trimmed. Empty or absent means the hosted service at https://quietguard.dev: an application on it only has to supply the key.
keystringnullThe per-project API token, sent as Authorization: Bearer <key>.
timeoutint3Per-request transport timeout, in seconds.
releasestringnullOptional release identifier (e.g. a commit SHA) attached to exception and log context.
trace_limitint00 (the default) ships the full stack trace with every exception; a positive value trims the payload to that many frames. The throw site, at the head of the stack since version 0.3, counts as one frame.
code_snippetsbooltrueSends, with each application frame, the five source lines on each side of its own, read from the file that ran. Never for a dependency; a line that names a scrub key and gives it a value is masked whole. false sends file and line only.
environmentslist of string[]Report only from these environments. Empty means report from all environments. Matched against kernel.environment.
scrublist of stringsee belowContext keys whose values are masked before sending (recursive, case-insensitive; from version 0.3.1, a hyphen counts as an underscore).
redactlist of stringemail, iban, nir, card, phoneValue shapes masked wherever they sit, message text and URL segments included. An empty list turns it off.
redact_custommap of string{}Your own shapes, as label: PCRE pattern. A label of customer_ref masks as [redacted:customer_ref].
logs.enabledboolfalseTurn log forwarding on. The handler service is always registered while the bundle is enabled; when false it drops every record. You still have to attach it to Monolog, see Usage.
logs.levelstringwarningMinimum level the handler captures (a Monolog level name).
logs.max_batchint200Flush the log buffer to the server once it reaches this many records.

Default scrub keys

When you do not set scrub, the bundle uses:

password, password_confirmation, passphrase, token, signature, secret, authorization, cookie, referer,
referrer, api_key

Setting scrub replaces this list, so include the defaults you still want to keep. From version 0.3.1, the scrubber also reaches the URL reported with each exception, a JSON value written as a string, and the values a log message carries when it starts with a URL or is JSON: see Usage.

Masking by the shape of the value

scrub looks at the key name. It never sees an address written into the free text of an exception message, into a URL segment, or into a field somebody called reference. redact looks at the value, on your own server, before anything is sent, and it is on by default with all five shapes.

That default was already applied before it was declared here, which is the reason it is worth stating plainly: the bundle masked values it never documented, and any attempt to configure it failed at container compilation with Unrecognized option. Both keys are part of the tree now.

yaml
monitor:
    # Drop the shapes that produce false positives on your data
    redact: ['email', 'iban', 'card']

    # Or send payloads untouched
    redact: []

    # Your own shapes
    redact_custom:
        customer_ref: '/CUST-\d{6}/'

Shapes carrying a check digit are verified rather than merely matched, so a sixteen digit order reference is not taken for a card number, and each mask names what it hid ([redacted:email]) so the message stays readable.

Environment variables

Nothing forces you to use environment variables, but it is the recommended pattern so secrets stay out of the repository. A typical wiring:

yaml
# config/packages/monitor.yaml
monitor:
    url: '%env(MONITOR_URL)%'
    key: '%env(MONITOR_KEY)%'
    release: '%env(default::MONITOR_RELEASE)%'
    environments: ['prod']
dotenv
# .env.local
MONITOR_URL=https://monitor.example.com
MONITOR_KEY=your-project-token
MONITOR_RELEASE=

The %env(default::MONITOR_RELEASE)% form falls back to an empty value when the variable is unset, so release simply stays empty.

Restricting environments

By default (environments: []) the bundle reports from every environment, including dev. To report only from production:

yaml
monitor:
    environments: ['prod']

Both the exception subscriber and the Monolog log handler check this list against kernel.environment before sending anything, so in any other environment nothing leaves your application, neither exceptions nor logs.

How the config maps to services

ConfigService built
url, key, timeout, release, environments, trace_limit, code_snippets, redact, redact_custommonitor.config (Config)
scrubmonitor.scrubber (Scrubber)
trace_limit, release, code_snippetsmonitor.payload_builder (ExceptionPayloadBuilder)
enabledmonitor.exception_subscriber, which receives the switch and applies it at runtime
—monitor.http_client (CurlHttpClient), monitor.reporter (Reporter), which takes the application's logger when one exists
logs.*monitor.log_handler (MonitorHandler), always registered while the bundle is enabled; with logs.enabled: false it drops every record, so a monolog.yaml referencing it keeps compiling

See Usage for how these services behave at runtime.

You are reading the Symfony Bundle v1.0 documentation.