> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fly.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Service Logs

> Stream logs for a service.



## OpenAPI

````yaml /sprites/api/openapi.json get /v1/sprites/{name}/services/{service_name}/logs
openapi: 3.1.0
info:
  title: Sprites API
  version: 0.1.12
  x-sprite-env-version: v0.0.1-rc48
servers:
  - url: https://api.sprites.dev
security: []
paths:
  /v1/sprites/{name}/services/{service_name}/logs:
    get:
      tags:
        - Services
      summary: Get Service Logs
      description: Stream logs for a service.
      operationId: sprite_env_get__service__logs
      parameters:
        - in: path
          name: name
          required: true
          schema:
            type: string
        - in: path
          name: service_name
          required: true
          schema:
            type: string
        - description: 'Number of lines to return from log buffer (default: all)'
          in: query
          name: lines
          required: false
          schema:
            description: 'Number of lines to return from log buffer (default: all)'
            type: integer
        - description: 'Time to follow new logs (default: `0`, no follow)'
          in: query
          name: duration
          required: false
          schema:
            description: 'Time to follow new logs (default: `0`, no follow)'
            type: integer
      responses:
        '200':
          content:
            application/x-ndjson:
              example:
                - data: |
                    Server started
                  timestamp: 1735988400000
                  type: stdout
                - data: |
                    Handling request from 127.0.0.1
                  timestamp: 1735988450000
                  type: stdout
                - data: |
                    Warning: slow query detected
                  timestamp: 1735988455000
                  type: stderr
                - log_files:
                    stdout: /.sprite/logs/services/webapp.log
                  timestamp: 1735988460000
                  type: complete
              schema:
                oneOf:
                  - $ref: '#/components/schemas/ServiceLogStdoutEvent'
                  - $ref: '#/components/schemas/ServiceLogStderrEvent'
                  - $ref: '#/components/schemas/ServiceLogExitEvent'
                  - $ref: '#/components/schemas/ServiceLogErrorEvent'
                  - $ref: '#/components/schemas/ServiceLogCompleteEvent'
          description: Success - Streaming NDJSON response
        '404':
          description: Not Found - Resource not found
        '500':
          description: Internal Server Error
      security:
        - bearerAuth: []
components:
  schemas:
    ServiceLogStdoutEvent:
      example:
        data: |
          Server listening on port 3000
        timestamp: 1767609000000
        type: stdout
      properties:
        data:
          description: Log line content
          type: string
        timestamp:
          description: Unix milliseconds
          type: integer
        type:
          const: stdout
          type: string
      required:
        - type
        - data
        - timestamp
      type: object
    ServiceLogStderrEvent:
      example:
        data: |
          Warning: deprecated API usage
        timestamp: 1767609000000
        type: stderr
      properties:
        data:
          description: Log line content
          type: string
        timestamp:
          description: Unix milliseconds
          type: integer
        type:
          const: stderr
          type: string
      required:
        - type
        - data
        - timestamp
      type: object
    ServiceLogExitEvent:
      example:
        exit_code: 0
        timestamp: 1767609000000
        type: exit
      properties:
        exit_code:
          description: Process exit code
          type: integer
        timestamp:
          description: Unix milliseconds
          type: integer
        type:
          const: exit
          type: string
      required:
        - type
        - exit_code
        - timestamp
      type: object
    ServiceLogErrorEvent:
      example:
        data: 'Failed to start service: command not found'
        timestamp: 1767609000000
        type: error
      properties:
        data:
          description: Error message
          type: string
        timestamp:
          description: Unix milliseconds
          type: integer
        type:
          const: error
          type: string
      required:
        - type
        - data
        - timestamp
      type: object
    ServiceLogCompleteEvent:
      example:
        log_files:
          combined: /.sprite/logs/services/webapp.log
          stderr: /.sprite/logs/services/webapp.log
          stdout: /.sprite/logs/services/webapp.log
        timestamp: 1767609000000
        type: complete
      properties:
        timestamp:
          description: Unix milliseconds
          type: integer
        type:
          const: complete
          type: string
      required:
        - type
        - timestamp
      type: object
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````