Send a log from the CLI
Learn how to send logs from your tasks to Hive using the Forge CLI
Now that you've built your first tasks, it's time to connect them to Hive for monitoring and observability. This tutorial will show you how to authenticate with Hive and automatically send logs when running your tasks from the CLI.
Having the Hive dashboard and CLI working together improves your development workflow since you can track CLI executions with a better UI, making it easier to monitor, debug, and iterate on your tasks.
Getting Your API Credentials
Before you can log in with the CLI, you need to obtain API credentials from the Hive dashboard:
1. Create API Keys in the Dashboard
- Visit forgehive.dev
- Log in to your account or create a new account
- Navigate to Dashboard → Settings
- In the API Keys section, click Create
- Enter a descriptive name for your API key (e.g., "My Local Development")
- Click Create
2. Copy Your Credentials
After creating the API key, you'll see:
- API Key and API Secret: A credential pair that authenticates your application (keep both secure!)
- CLI Login Command: A ready-to-use command for quick setup
The CLI login command will look like this:
forge auth:add "My Local Development" --apiKey "hk_1234..." --apiSecret "hs_5678..." --url "https://forgehive.dev"
You can simply copy and run this command in your terminal, and the profile will be created automatically. If you don't have the Forge CLI installed yet, install it globally using pnpm:
pnpm i -g @forgehive/forge-cli
Once you've installed the CLI and logged in with your credentials, you can start running tasks. When you run forge task:run
, the CLI will automatically:
- Push your task logs to forgehive.dev
- Create the task in your dashboard if it doesn't exist
- Create the project if it doesn't exist
This seamless integration means you can focus on building your tasks while the CLI handles the dashboard management for you.
Running Tasks and Sending Logs
Once you're authenticated, running your tasks with log collection is straightforward:
1. Navigate to Your Task Project
Go to the directory containing your Forge tasks:
cd my-task-project
2. Run Your Task
Use the forge task:run
command to execute your task:
forge task:run my-task
What happens when you run this:
- Your task executes normally
- All execution logs are automatically captured
- Logs are sent to your Hive dashboard in real-time
- The task and project are created in Hive if they don't exist yet
3. View Your Logs in the Dashboard
- Visit forgehive.dev and go to your dashboard
- Navigate to Tasks to see your executed tasks
- Click on your task to view detailed logs, including:
- Input parameters
- Output results
- Boundary interactions (API calls, database queries, etc.)
- Execution time and performance metrics (coming soon)
- Any errors that occurred
Example: Running a Stock Price Task
If you have a stock price task from the previous tutorials:
forge task:run getStockPrice --input '{"ticker": "AAPL"}'
You'll see output like:
✓ Task executed successfully
✓ Logs sent to Hive dashboard
✓ View results at: https://forgehive.dev/tasks/your-task-uuid
Next Steps
Great! You've connected your CLI tasks to Hive for powerful monitoring. But what about your production applications? In the next article, you'll discover how to:
- Send logs directly from your applications to Hive using the SDK
- Monitor production systems in real-time with automatic log capture
- Track performance and quality with built-in assessment tools
- Retrieve and analyze historical logs programmatically
- Handle errors gracefully while maintaining full observability
Ready to bring production-grade logging to your applications? Continue to: Send logs from your app