Attributes
Every log method accepts an optional second argument: an object of structured attributes attached to that single log entry. Use it to record the data that makes a log message useful to search and filter on later.
flare.logger.info('Order placed', {
orderId: 'ord_8231',
total: 49.99,
currency: 'EUR',
items: 3,
});
Attribute values can be strings, numbers, booleans, null, arrays, or nested objects:
flare.logger.warning('Validation failed', {
field: 'email',
errors: ['required', 'invalid_format'],
context: { formId: 'signup', step: 2 },
});
How attributes are handled
Attributes are frozen at the moment you record the log. The client encodes them immediately, so later changes to the original object don't affect the buffered entry. Pass the values you want captured at call time.
Attributes you set on a log entry apply only to that entry. They are not shared with other logs or with error reports.
Service-wide identity
Set serviceName once through configuration to attach it to every log batch (sent as service.name), rather than passing it per-call:
flare.configure({
enableLogs: true,
serviceName: 'storefront',
});
- On this page
- How attributes are handled
- Service-wide identity