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

# Log user feedback selectively with init_logger

> [!NOTE]
>
> **Applies to:**
>
> * Plan - Any
> * Deployment - Any
> *
> *

Summary

To minimize costs while collecting user feedback for dataset curation, use `init_logger()` to create a logger instance and only call `logger.log()` when users provide feedback (thumbs up/down). This approach avoids automatic tracing of every interaction and allows manual review before promoting logs to datasets for experiments.

## Configuration Steps

### Step 1: Initialize logger at startup

Create a logger instance at application startup instead of using traced decorators for automatic logging.

```text theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
import braintrust

logger = braintrust.init_logger(project="My App")

```

### Step 2: Log only on feedback events

Call `logger.log()` exclusively when user feedback is received to avoid logging every interaction.

```text theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
def on_feedback(user_input, agent_output, thumbs_up: bool):
    logger.log(
        input=user_input,
        output=agent_output,
        scores={"user_feedback": 1 if thumbs_up else 0},
        tags=["user-feedback"],
    )

```

### Step 3: Review and promote logs

Review logged interactions in the project Logs tab, add additional tags as needed, and promote entries to datasets for running experiments.

## Alternative: Direct Dataset Insertion

### Skip logging layer entirely

For maximum cost savings, insert directly into datasets when feedback is received without using the logging layer.

```text theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
import braintrust

dataset = braintrust.init_dataset(project="My App", name="user-feedback")

def on_feedback(user_input, agent_output, thumbs_up: bool):
    dataset.insert(
        input=user_input,
        expected=agent_output,
        metadata={"feedback": "positive" if thumbs_up else "negative"},
    )

```


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