-
Notifications
You must be signed in to change notification settings - Fork 3
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.
All logme command-line utilities use the same help layout:
- one line describing the utility
- copyright line
-
Usage:section - options / parameters description
Running logmefmt without arguments prints the same information as --help and
exits. It does not wait for stdin implicitly.
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.xmlInput 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.
Supported input formats:
textjsonxml
Supported output formats:
textjsonxml
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.
When converting text logs to JSON or XML, logmefmt parses known logme text
prefixes with regular expressions and extracts structured fields where possible:
timestamplevelprocess_idthread_idchannelsubsystemfilelinemethodmessage
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.
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.
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.
logme — flexible runtime logging system
Home · Getting Started · Architecture · Output · Backends · Configuration
GitHub: https://github.com/efmsoft/logme
- Home
- Getting Started
- Why logme?
- Core Concepts
- Logging Macros
- Fatal Handling
- Crash Logging
- glog Compatibility
- C API
- Choosing Logging Macros
- Function tracing
- Trace Points
- Override Scopes
- Advanced Features
- Collapse Logging
- Feature Map
- Overview
- Console Backend
- Debugger Backend
- File Backend
- File Rotation & Retention
- Buffer Backend
- Ring Buffer Backend
- SharedFile Backend
- Callback Backend
- Windows Event Log Backend
- Custom Backends
- Runtime Control
- Configuration
- Configuration JSON
- Control Server
- Environment Control
- Control Policies
- Trace Points
- Message Filtering