Skip to content

Logmefmt

Eduard Mishkurov edited this page May 3, 2026 · 3 revisions

logmefmt

logmefmt converts logme log streams between supported representations and can finalize append-friendly structured logs into standalone documents.

It is intended for post-processing logs, not for changing the runtime logging pipeline of an application.


Help and default behavior

All logme command-line utilities use the same help layout:

  1. one line describing the utility
  2. copyright line
  3. Usage: section
  4. options / parameters description

Running logmefmt without arguments prints the same information as --help and exits. It does not wait for stdin implicitly.


Basic usage

logmefmt --input text --output json --in app.log --out app.jsonl
logmefmt --input text --output xml --in app.log --out app.xml.log
logmefmt --input json --output json --finalize --in app.jsonl --out app.json
logmefmt --input xml --output xml --finalize --in app.xml.log --out app.xml

Input or output may be taken from standard streams when the corresponding file argument is not supplied by the command line. Use explicit arguments in scripts so the behavior is obvious.


Input and output formats

Supported input formats:

  • text
  • json
  • xml

Supported output formats:

  • text
  • json
  • xml

Text output is the traditional log-line representation. JSON output is written as one JSON object per event unless --finalize requests a complete document. XML output is written as one <event> element per event unless --finalize requests a complete document.


Text log parsing

When converting text logs to JSON or XML, logmefmt parses known logme text prefixes with regular expressions and extracts structured fields where possible:

  • timestamp
  • level
  • process_id
  • thread_id
  • channel
  • subsystem
  • file
  • line
  • method
  • message

If a line does not match the known text-log pattern, the converter preserves the whole line as message. This is safer than dropping data or inventing fields.

Trailing line endings are removed before the message is emitted to structured output. This prevents a Windows \r\n input line from becoming a literal carriage return inside <message> or a JSON string value.


Finalization

Runtime structured logging is append-friendly: a backend writes one JSON object or one XML <event> element per record. That format is good for logging because new events can be appended without rewriting the beginning or the end of the file.

--finalize converts such streams into complete standalone documents:

  • JSON events become an array
  • XML events become a document with a root element

Use this step when the result will be passed to tools that require a single valid JSON or XML document.


Relation to runtime structured output

Applications can write JSON or XML directly by setting OutputFlags::Format or by using the format field in JSON configuration. logmefmt is the companion utility for converting existing text logs and for finalizing append-friendly structured streams.

Clone this wiki locally