Log Levels
How Triton log levels work — the severity scale, choosing the right level, and tuning verbosity per environment with Log_Level__mdt instead of code changes.
A level answers one question about a log: how important is it? Triton uses levels for two things — telling humans how urgent a record is, and deciding at runtime whether a log is even worth saving. The second part is the powerful one: you can turn the firehose up in a sandbox and down in production without changing a line of code.
The scale
There are seven levels, ordered from least to most verbose:
ERROR
Something failed and needs attention — exceptions, failed callouts, broken invariants.
WARNING
Something recoverable or suspicious — retries, partial DML failures, deprecated paths.
INFO
Notable business events — "order placed", "sync completed". The default signal you'd want in production.
DEBUG
Developer-oriented detail useful while diagnosing.
FINE / FINER / FINEST
Increasingly chatty tracing — payload dumps, loop-level detail, everything-and-the-kitchen-sink.
Set the level on the builder, either explicitly or with the shorthand method:
Triton.log(Triton.t.summary('Order placed').level(TritonTypes.Level.INFO));
Triton.info(Triton.t.summary('Order placed')); // identicalRuntime filtering with Log_Level__mdt
Here's where levels earn their keep. Triton reads a custom metadata type, Log_Level__mdt, to decide which logs actually get persisted. Each record sets a threshold (a level) for some slice of your logs, scoped by any combination of five fields: Category, Type, Area, Component, and User.
The rule for a single record is simple: a log is saved when its level is at or below that record's threshold. Turn the threshold down and the chatty logs silently stop persisting; turn it up and they come back — all through metadata, deployable per environment.
An example
Say you create one Log_Level__mdt record:
Category
Apex
Level
INFO
Now, for any Apex log:
ERROR,WARNING,INFOlogs → saved (at or below theINFOthreshold)DEBUG,FINE,FINER,FINESTlogs → dropped
Bump that record to FINEST in your sandbox and every level flows through; drop it to WARNING in production and only warnings and errors persist. No code change, no redeploy of Apex.
Scoping a rule
A record's scope fields decide which logs it applies to. A record targets a log only when every field it fills in matches that log; any field left blank is a wildcard that matches everything. A record with only Category = Apex set therefore applies to all Apex logs, while one that also sets Component and User applies to a single component for a single user.
Category
The log's Category
e.g. Apex, LWC, Flow. Matched case-insensitively.
Type
The log's Type
e.g. Backend. Matched case-insensitively.
Area
The log's Area
Your functional area, e.g. Community. Matched case-insensitively.
Component
The component that produced the log
The Apex class name, the LWC component name, or the Flow API name — whichever matches the log's origin. Matched case-insensitively, but in full: My_Flow-4 is not My_Flow.
User
The running user
The 15-character Salesforce User Id. The one case-sensitive field — matching is exact on the 15-character form.
Matching on Category, Type, Area and Component is case-insensitive — they're free-text fields typed by hand, so apex and Apex mean the same thing. User is the exception: Salesforce Ids are case-sensitive base-62, and folding their case would collide distinct users, so a User Id is compared exactly, on its 15-character form.
Case is the only thing matching is forgiving about, because the scope fields are free text, not picklists. On Log_Level__mdt, Category__c, Type__c, Area__c and Component_Name__c are Text(255) and User_Id__c is Text(15) — only Level is a picklist. Nothing validates a scope value against anything real, so a rule keyed on a value that no longer exists — a renamed class, a retired Area, a Category removed in 2.0 — doesn't error. It silently stops matching, and that slice of logs falls back to whatever broader rule applies. When you rename or retire a value, re-key the rules that name it.
How multiple rules combine
When several records target the same log, the single most specific one wins — and its threshold overrides the others in both directions. A narrow rule can raise verbosity for its slice above a broad default, or lower it below one, so you can turn a single noisy component or user down while leaving everything else untouched.
Specificity is ranked by which fields a rule fills in, from narrowest to broadest scope:
User > Component > Area > Type > Category
Naming a narrower field always outranks any combination of broader ones — a rule that sets only User beats a rule that sets Component + Area + Type + Category. If two rules are equally specific (they fill in the same fields), the more restrictive (less verbose) level wins, so the outcome never depends on metadata order.
Two examples, both starting from a global default record at INFO:
Boost one slice. Add
Area = RestAPI,Level = FINEST. ForRestAPIlogs the more specific rule wins → every level flows through, while everything else stays atINFO.Silence one slice. Add
Component = NoisyController,Level = ERROR. For that component the more specific rule wins → onlyERRORpersists, while everything else still logs atINFO.
Choosing levels well
Reserve
ERRORfor things a human should look at. If everything is an error, nothing is.Make
INFOyour production signal. Ask "would I want to see this in prod?" — if yes, it's probablyINFOor higher.Push volume down the scale. Loop bodies, payload dumps, and step-by-step traces belong at
FINEand below, where filtering can switch them off cheaply.Don't gate logs with
ifstatements. Resistif (debugMode) Triton.debug(...). Log at the right level and letLog_Level__mdtdecide — that's the whole point.
Related reading
Classifying logs by Category, Type & Area — three of the fields that scope level filtering.
Log Levels: When to Use What in Best Practices, for deeper guidance and examples.
Last updated