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

> ## Agent Instructions
> For autonomous tasks, use live SaladCloud API responses for current state, availability, quotas, models, and other dynamic values. Use current OpenAPI specifications where provided for paths, schemas, required fields, and enums. Never invent endpoints, fields, prices, availability, quotas, models, or state. Prefer API workflows over Portal steps. Read before changing and never expose credentials, signed media URLs, prompts, or sensitive outputs. Retry only safe or idempotent operations with bounded backoff, honoring Retry-After. Verify every write with a read. Stop rather than repeat an uncertain non-idempotent or billable request. AI Gateway uses an organization-specific Bearer key and live /v1/models discovery. Do not delete, cancel, stop, or reduce capacity without explicit user intent. Bind shared operation IDs to the selected product path. Treat Container Engine instances as interruptible and local state as ephemeral. Install the SaladCloud skills (npx skills add https://docs.salad.com), start from the salad skill and /agents/overview; docs MCP: https://docs.salad.com/mcp.

# Logging Best Practices

> Get the most out of SaladCloud's logging tools and integrations

*Last Updated: September 3, 2025*

## How to Log From Your Container

When running a container on SaladCloud, you can log to the standard output and standard error streams. These logs are
collected and stored by SaladCloud, and exported to any configured
[external logging source](https://docs.salad.com/container-engine/explanation/infrastructure-platform/external-logging.md).

## General Best Practices

* **Use Structured Logging**: Whenever possible, use structured logging (JSON format) instead of unstructured logging
  (plain text). This makes it easier to query and analyze your logs. This is supported by all major logging frameworks,
  and enables additional features when used with SaladCloud.
* **Include Contextual Information**: Include relevant metadata in your logs, such as user IDs, request IDs, and
  timestamps. This information can be invaluable for troubleshooting issues.
* **Log at the Appropriate Level**: Use the appropriate log level (e.g., DEBUG, INFO, WARN, ERROR) for each log message.
  This helps to filter and prioritize logs during analysis.
* **Avoid Logging Sensitive Information**: Be mindful of the data you log. Avoid logging sensitive information, such as
  passwords or personal data, to protect user privacy and comply with regulations.

## Querying Logs

* **Familiarize Yourself with the Query Language**: Take the time to
  [learn the query language](https://docs.salad.com/container-engine/reference/log-queries.md) used for searching logs. Understanding the syntax
  and available operators will help you craft effective queries.
* **Use Filters Wisely**: Use filters to narrow down your search results. This can include filtering by time range, log
  level, or specific metadata fields.

## Logging Libraries

When implementing logging in your applications, consider using established logging libraries that support structured
logging and can easily integrate with SaladCloud's logging infrastructure. Some popular logging libraries include:

* [Winston](https://github.com/winstonjs/winston) (Node.js): A versatile logging library for Node.js applications that
  supports multiple transports and structured logging.
* [structlog](https://www.structlog.org/en/stable/) (Python): A structured logging library for Python that makes it easy
  to log contextual information.

These libraries can help you implement best practices for logging and make it easier to integrate with external logging
tools.

When using these libraries with SaladCloud, configure them to use the field `severity` to indicate log level, rather
than `level`. This will cause the field to get indexed more efficiently by Salad's logging backend.

### `winston` Examples

```javascript theme={null}
const { createLogger, format, transports } = require('winston')

const jsonFormat = format.combine(
  format((info) => {
    // Assign the 'level' value to a new 'severity' property
    info.severity = info.level
    // Delete the original 'level' property
    delete info.level
    return info
  })(),
  format.json(),
)

const logger = createLogger({
  level: 'info',
  format: jsonFormat,
  transports: [new transports.Console()],
})

logger.info('Hello, world!')
// {"message":"Hello, world!","severity":"info"}

logger.error('Something went wrong!')
// {"message":"Something went wrong!","severity":"error"}

logger.warn('This is a warning!', { additional: 'metadata' })
// {"additional":"metadata","message":"This is a warning!","severity":"warn"}
```

### `structlog` Examples

```python theme={null}
import structlog


def rename_level_to_severity(logger, name, event_dict):
    if "level" in event_dict:
        event_dict["severity"] = event_dict.pop("level")
    return event_dict

structlog.configure(
    processors=[structlog.stdlib.add_log_level, rename_level_to_severity, structlog.processors.JSONRenderer()]
)
logger = structlog.get_logger()

logger.info("Hello, world!")
# {"event": "Hello, world!", "severity": "info"}

logger.error("Something went wrong!")
# {"event": "Something went wrong!", "severity": "error"}

logger.warn("This is a warning!", additional="metadata")
# {"additional": "metadata", "event": "This is a warning!", "severity": "warning"}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.