Use it when configuring, checking or troubleshooting Logging in Scripting.
Logging · Scripting
Script Logging creates attributable execution evidence for decisions, actions, failures and timing. Useful logs are structured enough to correlate a run without exposing secrets or being mistaken for proof of target state.
1. Log what the script does: start, inputs (not secrets), actions, results, errors.
2. Timestamps and levels.
3. Central logs for scheduled scripts.
4. Structured logs where possible.
5. Avoid secrets.
action → log line → central log
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
run identity → input/context record → decision record → action/result record → exception/exit record → target evidence correlation → retention
Healthy evidence: logs are attributable, structured, time-correlated, redacted and consistent with exit/exception and target-side evidence.
Step 2 Failure modes and next checks Narrow the fault
Suspicious evidence: free-form print-only diagnostics, secrets in logs, missing timestamps/correlation, success messages before verification or logs that contradict process status.
A log record shows only that the logging path produced a message, but it does not show the external action or target state described by that message.
Step 3 Common mistakes Narrow the fault
- No timestamps in logs.
Step 4 Where it fails Narrow the fault
Where Logging usually goes wrong: correlation identity, structured fields, redaction, retention and reconstructing execution without conflating logs with truth.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Log emitted ≠ action succeeded; logging records what the script observed or intended, not independent target truth.
- Verbose logging ≠ useful evidence; volume without correlation, structure or severity can hide the failure path.
- No log entry ≠ action did not occur; logging may fail, be filtered or terminate before flush.
- Debug detail ≠ safe to retain; secrets, tokens and sensitive payloads require redaction.
logger -t <script> 'message'— syslog from BashWrite-Information / Start-Transcript— PowerShell loggingpython3 -c 'import logging'— Python logging module
ReferenceWhat it is1 section · depth on demand
Core model
Assign a run/correlation identity, record major inputs and decisions in redacted form, timestamp external actions and results, separate severity levels and preserve enough context to reconstruct the execution path.
ReferenceImportant terms & boundaries2 sections · depth on demand
What this shows and what it does not
Scripting owns execution-log semantics and redaction; Logging/SIEM branches own centralized collection/correlation and target Domains own authoritative platform logs.
In depth
Logging records what a script did, when, with which inputs and results, so runs can be audited and failures diagnosed later. Good logs are structured, timestamped and free of secrets.
| Level | Use |
|---|---|
| DEBUG | Detailed values for troubleshooting |
| INFO | Normal progress ("backed up sw01") |
| WARNING | Recoverable problems |
| ERROR | Item failed |
| CRITICAL | Script cannot continue |
import logging
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
log = logging.getLogger("backup")
log.info("backup start hosts=%d", len(hosts))
Write logs to stdout/stderr when running under a scheduler or CI so the platform captures them.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Scripting > Logging. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.python.org/3/ · confidence 94%Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Logging scripting boundary map
Fast input, runtime, execution, result and verification boundaries for Logging.
| Boundary | Healthy evidence | Suspicious evidence |
|---|---|---|
| Input / runtime | Effective inputs, runtime, working context and dependency versions are explicit | Hidden defaults, stale environment, wrong interpreter/path or unvalidated input |
| Logic / execution | Branch/function/module decisions and external actions expose per-operation results | Swallowed failures, shell reinterpretation, blind retries or last-result-wins behavior |
| Result / proof | Exit/exception/log evidence is correlated with independent target read-back | Process success or printed output treated as target success |
| Recovery / troubleshooting | First failed boundary is preserved, changed minimally and retested | Random edits, catch-all suppression or evidence destroyed before diagnosis |
Deep reference
Healthy vs suspicious evidence
Output interpretation
For Logging, rely on structured fields and stable IDs (correlation identity, structured fields, redaction, retention and reconstructing execution without conflating logs with truth) rather than text formatted for display.