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

# Send logs

> Get up and running in under 5 minutes

### Install SDK

<Info>
  **Prerequisite** You should have Python `v3.10` or higher installed.
</Info>

Install the sdk via your preferred package manager

<CodeGroup>
  ```bash uv theme={null}
  uv add navigator-sdk
  ```

  ```bash poetry theme={null}
  poetry add navigator-sdk
  ```

  ```bash pip theme={null}
  pip install navigator-sdk
  ```
</CodeGroup>

### Setup logger

There are two ways you can initialize the logger

<AccordionGroup>
  <Accordion icon="sliders-horizontal" title="Using .env variables">
    Set the following environment variables, all of them are required.

    ```bash theme={null}
    ENVIRONMENT         = Environment
    NAVIGATOR_API_URL   = https://api.usenavigator.co
    NAIGATOR_API_KEY    = pk_live_abc..xyz
    NAVIGATOR_DOMAIN    = Domain name (i.e. Data Infrastructure)
    NAVIGATOR_SERVICE   = Service name (i.e. Airflow)
    NAVIGATOR_TRACE_ID  = Default trace ID for correlating logs
    ```

    And then initialize the logger with:

    <CodeGroup>
      ```bash python theme={null}
      from navigator_sdk import setup_logger

      logger = setup_logger()
      ```

      ```bash node theme={null}
      ```
    </CodeGroup>
  </Accordion>

  <Accordion icon="keyboard" title="Initializing at runtime">
    You can also pass the configuration values at runtime

    ```bash python theme={null}
    from navigator_sdk import setup_logger

    logger = setup_logger(
        environment='production',
        api_url='https://api.usenavigator.co',
        api_key='pk_live_abc..xyz',
        domain='domain',
        service='service',
        trace_id='trace_id'
    )
    ```
  </Accordion>
</AccordionGroup>

You could also define both. However, note that values defined at runtime will take precedence over env variables. For example, if you need dynamic `trace_id` for each n number of scripts, you can set a default value in `.env` file and override by setting the same at runtime.

### Send logs

Your logger is now ready to send logs.

```bash python theme={null}
logger.info("Hello world")
```

Go to [app.usenavigator.co](https://app.usenavigator.co) to start using Navigator.

### Optional Configuration

By default, the logging via sdk is *synchronous* and *best-effort with retries*. You can configure retries and delays but is optional.

<AccordionGroup>
  <Accordion icon="list-start" title="Retry">
    Add these in addition to the required env variables

    ```bash theme={null}
    NAVIGATOR_MAX_RETRIES       = Number of retries after initial attempt (default: 3)
    ```
  </Accordion>

  <Accordion icon="loader" title="Delay (exponential backoff)">
    Add these in addition to the required env variables

    ```bash theme={null}
    NAVIGATOR_RETRY_BASE_DELAY  = Base retry delay in seconds (default: 1.0)
    NAVIGATOR_RETRY_MAX_DELAY   = Max retry delay in seconds (default: 60.0)
    ```
  </Accordion>
</AccordionGroup>

### Next Steps

<CardGroup cols={2}>
  <Card title="Examples" icon="gamepad" href="../examples">
    Get your docs set up locally for easy development
  </Card>

  <Card title="Key concepts" icon="globe" href="../essentials#overview">
    Get to know the essentials
  </Card>
</CardGroup>
