Get Container Logs
Path Parameters
The container ID or name
Query Parameters
The environment ID where the container is located
Number of lines to retrieve from the end of the logs
Response
The container log output as a string
Error Responses
Error message if the request fails
Additional error details
200- Success403- Permission denied500- Failed to get container logs
Example
Response Example
Stream Container Logs
Path Parameters
The container ID or name
Query Parameters
The environment ID where the container is located
Number of historical log lines to retrieve before starting the stream
Response Format
The endpoint returns a Server-Sent Events (SSE) stream with the following event types: Event:connected
Emitted immediately when the stream connection is established.
The container ID
The container name
Whether the container has TTY enabled
log
Emitted for each log line from the container.
The log line text
The container name
The output stream - either “stdout” or “stderr” (only present for non-TTY containers)
end
Emitted when the log stream ends (e.g., container stopped).
Reason the stream ended
error
Emitted if an error occurs during streaming.
Error message
Error Responses
Status Codes:200- SSE stream established403- Permission denied503- Edge agent not connected (for Hawser Edge environments)
Example
Response Example
Notes
- Keepalive comments (
: keepalive) are sent every 5 seconds to maintain the connection through proxies like Traefik - For containers with TTY enabled, the
streamfield is not present in log events - For non-TTY containers, Docker multiplexes stdout and stderr which are demultiplexed by the API
- The stream follows logs in real-time until the client disconnects or the container stops
- Both stdout and stderr streams are included in the output
- Timestamps are included if the container was configured with
--log-opt timestamps=true
