cf logs gives you a wall of prefixed, multi-line text with JSON payloads
buried inside it. cflogs turns that into clean, structured JSON or CSV you
can filter, read, or pipe into other tools — working from either a captured
log file or a live cf logs stream.
- No more eyeballing raw
cf logsoutput. Timestamps, app/instance prefixes,OUT/ERRmarkers, and embedded JSON payloads are parsed into clean structured records automatically. - One unified stream across apps. Tail a single app or several at once —
multiple
cf logsstreams are merged into one, with anappcolumn so you can tell records apart, which is handy when debugging across microservices. - Query logs instead of grepping them. A small filter expression language
(
=,>,<,contains,startswith,endswith, combined withand/or/parentheses) replaces chains ofgrep/awk/jq. - Control signal vs. noise. Pick exactly which properties you see — sane
defaults,
-pto add more,--all-propsfor everything, or-ifor an interactive picker. - JSON or CSV, your choice. Feed JSON into
jqor other tooling, or export CSV straight into Excel/spreadsheets for further analysis. - Works with the
cfCLI you already have. No CF plugin to install —cflogsjust wrapscf logs. - Zero runtime dependencies. Small, focused codebase; fast to install and fast to run.
npm install -g cf-log-utilcflogs (<input-file> | -a <name>) [-p prop1,prop2] [--all-props] [-i] [-f <expr>] [--recent] [--csv]
| Option | Description |
|---|---|
<input-file> |
Transform a captured log file (prints a JSON array). |
-a <name> |
Run cf logs <name> and stream it as NDJSON. Repeatable or comma-separated to merge multiple apps into one stream (adds a synthetic app column). |
--recent |
Pass through to cf logs --recent (no streaming). Requires -a. |
| Option | Description |
|---|---|
-p <prop,...> |
Include comma-separated additional properties. |
--all-props |
Include every property found in each record, after the default properties and app. |
-i, --interactive |
Interactively select which properties (discovered from an input file) to include. |
-f <expr> |
Filter log entries using a filter expression (see below). |
--csv |
Output as CSV instead of JSON. |
By default the following properties are included:
logger, timestamp, level, correlation_id, msg, stacktrace.
= > < contains startswith endswith
Combine comparisons with and, or, and parentheses ( ). String values are
single-quoted; contains/startswith/endswith are case-insensitive.
cflogs logs.json -p thread,request_id
cflogs logs.json --all-props
cflogs logs.json --interactive
cflogs logs.json -f "logger = 'myapp'"
cflogs logs.json -f "logger = '4' or logger = '10'"
cflogs logs.json -f "(logger = '4' or msg contains '40') and correlation_id = '439034'"
cflogs logs.json --csv
cflogs -a my-app -f "level = 'ERROR'"
cflogs -a my-app --recent
cflogs -a app1,app2 -f "level = 'ERROR'"- Node.js >= 18
- The Cloud Foundry CLI (
cf) on yourPATH, and logged in, when using-a <name>to stream live logs.
npm install
npm testThe codebase is split into small, independently testable modules under src/lib:
filter.js— the-ffilter expression tokenizer/parser/evaluatorargs.js— CLI argument parsing (throwsCliErroron invalid input)log-processing.js— extracting/transforming JSON log recordsoutput.js— JSON/CSV output formattinginteractive.js— the-iinteractive property selectorcf-stream.js— spawning and mergingcf logschild processes
src/cli.js wires these together; bin/cflogs.js is the published executable.