JSON Output Format
JSON is one of the output formats for logget. It provides structured data that's easy to parse programmatically.
Usage
# Explicit JSON output
logget --logs --network --json https://example.com
Output Schemas
When using --json, logget outputs structured JSON data. The format depends on whether you're in follow mode (streaming) or batch mode.
Batch Mode (Full Output)
In batch mode, the complete JSON output contains a single OutputData object:
{
"url": "https://example.com",
"logs": [
{
"level": "INFO",
"message": "Console log message",
"time": "2024-10-31T23:00:00Z",
"source": "console"
}
],
"network": [
{
"url": "https://example.com/api/data",
"method": "GET",
"status": 200,
"headers": {
"Content-Type": "application/json",
"Content-Length": "1234"
},
"timestamp": "2024-10-31T23:00:00Z",
"type": "application/json",
"size": 1234,
"resourceType": "XHR"
}
],
"duration": "3.456789s"
}
Follow Mode (Streaming)
In follow mode (-f), each log entry and network request is output as a separate JSON object (one per line):
{"level":"INFO","message":"Log message","time":"2024-10-31T23:00:00Z","source":"console"}
{"url":"https://example.com","method":"GET","status":200,"headers":{"Content-Type":"text/html"},"timestamp":"2024-10-31T23:00:01Z","type":"text/html","size":184,"resourceType":"Document"}
Field Descriptions
OutputData (Batch Mode Only)
url(string): Visited URLlogs(array, optional): Array ofLogEntryobjectsnetwork(array, optional): Array ofNetworkEntryobjectsduration(string): Total time taken to load the page
LogEntry
level(string): Log level (DEBUG,INFO,WARN,ERROR,FATAL,LOG,TRACE)message(string): The log message contenttime(string): Timestamp in RFC3339 format (ISO 8601)source(string): Source of the log ("browser"or"console")
NetworkEntry
url(string): Request URLmethod(string): HTTP method (e.g.,GET,POST,PUT,DELETE)status(integer): HTTP status code (e.g., 200, 404, 500)headers(object): Response headers as key-value pairs (string keys and values)timestamp(string): Timestamp in RFC3339 format (ISO 8601)type(string): MIME type of the response (e.g.,"text/html","application/json")size(integer): Size of the response in bytesresourceType(string): Resource type (e.g.,"Document","XHR","Image","Script","Stylesheet","Font","Media","Manifest","WebSocket","Other")duration(float, optional): Total request duration in millisecondsdurationFormatted(string, optional): Formatted duration (e.g.,"123.45ms"or"1.23s")timeToFirstByte(float, optional): Time to first byte (TTFB) in millisecondstimeToFirstByteFormatted(string, optional): Formatted TTFB (e.g.,"50.23ms"or"0.50s")connectTime(float, optional): Connection establishment time in millisecondsconnectTimeFormatted(string, optional): Formatted connect timednsLookupTime(float, optional): DNS lookup time in millisecondsdnsLookupTimeFormatted(string, optional): Formatted DNS lookup timesslTime(float, optional): SSL/TLS handshake time in milliseconds (HTTPS only)sslTimeFormatted(string, optional): Formatted SSL timesendTime(float, optional): Time to send request in millisecondssendTimeFormatted(string, optional): Formatted send timewaitTime(float, optional): Wait time (server processing) in millisecondswaitTimeFormatted(string, optional): Formatted wait timereceiveTime(float, optional): Time to receive response headers in millisecondsreceiveTimeFormatted(string, optional): Formatted receive timecontentDownloadTime(float, optional): Full content download time (body + headers) in millisecondscontentDownloadTimeFormatted(string, optional): Formatted content download timequeuedTime(float, optional): Time from navigation start to request start in millisecondsqueuedTimeFormatted(string, optional): Formatted queued timerequestStartTime(float, optional): Request start time relative to navigation start in millisecondsrequestStartTimeFormatted(string, optional): Formatted request start timeresponseStartTime(float, optional): Response start time relative to navigation start in millisecondsresponseStartTimeFormatted(string, optional): Formatted response start timetotal(float, optional): Sum of all timing phases (Queued + DNS + Connect + SSL + Send + Wait + Receive + ContentDownload) in millisecondstotalFormatted(string, optional): Formatted total time (e.g.,"863.12ms"or"0.86s")
Resource Types
"Document": HTML documents"XHR": XMLHttpRequest / Fetch API requests"Image": Images (PNG, JPEG, GIF, etc.)"Script": JavaScript files"Stylesheet": CSS files"Font": Web fonts"Media": Audio/video files"Manifest": Web app manifests"WebSocket": WebSocket connections"Other": Other resource types
Output Format
Single Line Format (Follow Mode)
In follow mode, each JSON object is written on a single line (JSONL/NDJSON format):
{"level":"INFO","message":"App started","time":"2024-10-31T23:00:00Z","source":"console"}
{"url":"https://example.com/","method":"GET","status":200,"resourceType":"Document"}
This format is:
- Easy to stream and process line by line
- Efficient for large outputs
- Compatible with tools like
jq
Saving to File
# Save to file
logget --json --logs --network --output results.json https://example.com
# Append to file
logget --json --logs --network --append --output results.json https://example.com
Follow Mode
In follow mode (-f), JSON objects are streamed one per line as they occur:
logget -f --json --logs --network https://example.com
This allows real-time processing of logs and network requests.
Examples
Basic Console Logs
logget --json --logs https://example.com
Output (follow mode):
{"level":"INFO","message":"Application started","time":"2024-10-31T23:00:00Z","source":"console"}
{"level":"WARN","message":"Deprecated API","time":"2024-10-31T23:00:01Z","source":"console"}
Network Requests
logget --json --network https://example.com
Output (follow mode):
{"url":"https://example.com/","method":"GET","status":200,"headers":{"Content-Type":"text/html"},"timestamp":"2024-10-31T23:00:00Z","type":"text/html","size":1256,"resourceType":"Document"}
{"url":"https://example.com/api/data","method":"GET","status":200,"headers":{"Content-Type":"application/json"},"timestamp":"2024-10-31T23:00:01Z","type":"application/json","size":456,"resourceType":"XHR"}
Combined Output
logget --json --logs --network https://example.com
Output (follow mode, mixed console logs and network requests):
{"level":"INFO","message":"App started","time":"2024-10-31T23:00:00Z","source":"console"}
{"url":"https://example.com/","method":"GET","status":200,"resourceType":"Document"}
{"level":"ERROR","message":"API error","time":"2024-10-31T23:00:01Z","source":"console"}
{"url":"https://example.com/api/data","method":"GET","status":500,"resourceType":"XHR"}