Skip to main content

HAR Output Format

HAR (HTTP Archive) format is a standard format for storing HTTP request/response data. HAR files can be analyzed with browser DevTools, HAR viewers, or other analysis tools.

Usage

# Output HAR to stdout
logget --har --network https://example.com

# Output HAR to file
logget --har --network --output network.har https://example.com
info

HAR format only includes network data. Use --network with --har.

Output Schemas

When using --har, logget outputs HAR format data following the HTTP Archive specification (version 1.2). The structure is always a single HAR file object, regardless of follow mode.

HAR Structure

{
"log": {
"version": "1.2",
"creator": {
"name": "logget",
"version": "2.0"
},
"pages": [...],
"entries": [
{
"request": {...},
"response": {...},
"timings": {...},
"cache": {...},
"time": 123.45,
"startedDateTime": "2024-10-31T23:00:00.000Z"
}
]
}
}

Field Descriptions

Root Object

  • log (object, required): The log object containing all HAR data

Log Object

  • version (string, required): HAR format version (e.g., "1.2")
  • creator (object, required): Information about the tool that created the HAR
    • name (string): Tool name (e.g., "logget")
    • version (string): Tool version (e.g., "2.0")
  • pages (array, optional): Array of page objects representing pages loaded
  • entries (array, required): Array of entry objects representing HTTP requests/responses

Page Object

Represents a page load:

{
"startedDateTime": "2024-10-31T23:00:00.000Z",
"id": "page_1",
"title": "Example Domain",
"pageTimings": {
"onContentLoad": 123.45,
"onLoad": 234.56,
"onDOMContentLoaded": 112.34
}
}
  • startedDateTime (string, required): Page load start time (ISO 8601)
  • id (string, required): Unique page identifier
  • title (string, required): Page title
  • pageTimings (object, optional): Page timing information

Entry Object

Represents a single HTTP request/response:

{
"startedDateTime": "2024-10-31T23:00:00.000Z",
"time": 123.45,
"request": {
"method": "GET",
"url": "https://example.com/",
"httpVersion": "HTTP/1.1",
"headers": [
{"name": "User-Agent", "value": "Mozilla/5.0..."},
{"name": "Accept", "value": "text/html"}
],
"queryString": [],
"cookies": [],
"headersSize": 234,
"bodySize": 0
},
"response": {
"status": 200,
"statusText": "OK",
"httpVersion": "HTTP/1.1",
"headers": [
{"name": "Content-Type", "value": "text/html"},
{"name": "Content-Length", "value": "1256"}
],
"cookies": [],
"content": {
"size": 1256,
"mimeType": "text/html"
},
"redirectURL": "",
"headersSize": 345,
"bodySize": 1256
},
"cache": {},
"timings": {
"blocked": 5.12,
"dns": 5.34,
"connect": 10.12,
"ssl": 20.56,
"send": 2.10,
"wait": 30.45,
"receive": 15.67
},
"serverIPAddress": "93.184.216.34",
"connection": "443"
}

Entry Fields

  • startedDateTime (string, required): Request start time (ISO 8601)
  • time (float, required): Total request time in milliseconds
  • request (object, required): Request object
  • response (object, required): Response object
  • cache (object, optional): Cache information
  • timings (object, required): Timing information
  • serverIPAddress (string, optional): Server IP address
  • connection (string, optional): Connection identifier

Request Object

  • method (string, required): HTTP method (GET, POST, etc.)
  • url (string, required): Request URL
  • httpVersion (string, required): HTTP version (e.g., "HTTP/1.1")
  • headers (array, required): Array of header objects {name, value}
  • queryString (array, optional): Array of query parameter objects {name, value}
  • cookies (array, optional): Array of cookie objects
  • headersSize (integer, optional): Size of request headers in bytes
  • bodySize (integer, optional): Size of request body in bytes
  • postData (object, optional): POST data (for POST requests)

Response Object

  • status (integer, required): HTTP status code
  • statusText (string, required): HTTP status text (e.g., "OK", "Not Found")
  • httpVersion (string, required): HTTP version
  • headers (array, required): Array of header objects {name, value}
  • cookies (array, optional): Array of cookie objects
  • content (object, required): Response content
    • size (integer): Content size in bytes
    • mimeType (string): MIME type
    • text (string, optional): Response body text (may be truncated)
  • redirectURL (string, optional): Redirect URL if applicable
  • headersSize (integer, optional): Size of response headers in bytes
  • bodySize (integer, optional): Size of response body in bytes

Timings Object

All timing values are in milliseconds:

  • blocked (float): Time spent in queue
  • dns (float): DNS lookup time
  • connect (float): Connection establishment time
  • ssl (float): SSL/TLS handshake time (HTTPS only)
  • send (float): Time to send request
  • wait (float): Wait time (server processing) - TTFB
  • receive (float): Time to receive response
info

-1 indicates that the timing information is not available.

Output Format

HAR format always outputs a complete HAR file structure, even in follow mode. The file contains all network entries captured during the session.

Saving to File

# Save to file
logget --har --network --output network.har https://example.com

# Append to file
logget --har --network --append --output network.har https://example.com

Follow Mode

In follow mode (-f), HAR format still outputs a complete HAR file structure. The file is written incrementally as network requests are captured:

logget -f --har --network https://example.com

Examples

Basic Network Capture

logget --har --network https://example.com

Output:

{
"log": {
"version": "1.2",
"creator": {
"name": "logget",
"version": "2.0"
},
"pages": [
{
"startedDateTime": "2024-10-31T23:00:00.000Z",
"id": "page_1",
"title": "Example Domain",
"pageTimings": {
"onContentLoad": 123.45,
"onLoad": 234.56
}
}
],
"entries": [
{
"startedDateTime": "2024-10-31T23:00:00.000Z",
"time": 123.45,
"request": {
"method": "GET",
"url": "https://example.com/",
"httpVersion": "HTTP/1.1",
"headers": [
{"name": "User-Agent", "value": "Mozilla/5.0..."},
{"name": "Accept", "value": "text/html,application/xhtml+xml"}
],
"queryString": [],
"cookies": [],
"headersSize": 234,
"bodySize": 0
},
"response": {
"status": 200,
"statusText": "OK",
"httpVersion": "HTTP/1.1",
"headers": [
{"name": "Content-Type", "value": "text/html; charset=UTF-8"},
{"name": "Content-Length", "value": "1256"}
],
"cookies": [],
"content": {
"size": 1256,
"mimeType": "text/html"
},
"redirectURL": "",
"headersSize": 345,
"bodySize": 1256
},
"cache": {},
"timings": {
"blocked": 5.12,
"dns": 5.34,
"connect": 10.12,
"ssl": 20.56,
"send": 2.10,
"wait": 30.45,
"receive": 15.67
}
}
]
}
}

Best Practices

  1. Use with Network Only: Remember to use --network with --har
  2. File Size: HAR files can grow large; consider filtering if needed
  3. Privacy: HAR files may contain sensitive data; be careful when sharing
  4. Analysis Tools: Use browser DevTools or HAR viewers for visual analysis
  5. Automation: Use HAR format for automated analysis workflows

Viewing HAR Files

Browser DevTools

  1. Open Chrome/Edge DevTools (F12)
  2. Go to Network tab
  3. Click the "Import HAR file" button (or right-click → Load HAR)
  4. Select your HAR file

Online HAR Viewers