Access Usage Logs
1. Console Access
1
Log in to Console
Visit Laozhang API Console and log in
2
Open Usage Logs

3
View Log Details
In the log list you can view:
- Request Time: When the request occurred
- Model Used: Which model was called
- Token Count: Number of tokens used
- Cost: This request’s cost
- Request Status: Success/failure status
- Request Parameters: Detailed request information
2. API Query
Get usage logs via API:Log Information Details
Basic Information
Field | Description | Example |
---|---|---|
Request ID | Unique identifier | req_123456789 |
Timestamp | Request time | 2024-01-15 14:30:25 |
Model | Model used | gpt-4-turbo |
Status | Request status | success / error |
Usage Statistics
Field | Description | Calculation Method |
---|---|---|
Prompt Tokens | Input token count | Calculated based on input text |
Completion Tokens | Output token count | Calculated based on generated text |
Total Tokens | Total token count | Prompt + Completion |
Cost | Request cost | Token count × unit price |
Request Details
Field | Description | Use Case |
---|---|---|
API Key | Key used | Differentiate between different application sources |
IP Address | Request source IP | Security audit, access analysis |
User Agent | Client information | Technical support, issue troubleshooting |
Request Parameters | Detailed parameters | Reproduce issues, optimize requests |
Error Information
When request fails, additional information is recorded:Field | Description | Example |
---|---|---|
Error Code | Error type code | insufficient_balance |
Error Message | Error description | ”Insufficient balance” |
Error Details | Detailed error information | Stack trace, parameter validation errors |
Log Filtering and Search
Time Range Filtering
Model Filtering
Status Filtering
Advanced Search
Usage Analysis
Cost Analysis
Analyze usage costs:Usage Trend Analysis
Peak Time Analysis
Error Rate Analysis
Export Logs
Export to CSV
Export to JSON
Generate Report
Automated Monitoring
Set Up Alert System
Regular Report Generation
Common Questions
How long are logs retained?
How long are logs retained?
Log Retention Policy:
- Standard users: 30 days
- Professional users: 90 days
- Enterprise users: 1 year
- Can purchase extended log retention service
- Support custom retention period
- Support historical log export
How to view logs for specific API Key?
How to view logs for specific API Key?
Filtering by API Key:In console:
- Select “Filter by API Key” on log page
- Choose the API Key you need to view
- View filtered results
Can I delete logs?
Can I delete logs?
Log Deletion Policy:
- Logs cannot be manually deleted (for audit and billing purposes)
- Logs are automatically deleted after retention period expires
- Can contact support for special deletion requests
- Logs do not contain sensitive information (like prompts)
- Only statistical information and metadata are recorded
- Can enable “Privacy Mode” to reduce log details
Log timestamp is incorrect
Log timestamp is incorrect
Timestamp Format:
- All timestamps use UTC time
- Console can display local time
- API returns UTC timestamps
How to export large volumes of logs?
How to export large volumes of logs?
Batch Export:
-
Use Pagination
-
Export in Chunks
- Export by month to avoid single file being too large
- Use compressed format to reduce storage space
- Consider using database storage instead of files
Best Practices
1. Regular Monitoring
Establish regular monitoring mechanisms:2. Alert Configuration
Set reasonable alert thresholds:- Cost alert: Set based on daily average + 2 standard deviations
- Error rate alert: Over 10% trigger alert
- Token alert: Abnormally high single request tokens
3. Data Backup
Regularly backup important logs:- Export and save monthly logs
- Use version control to manage reports
- Consider using cloud storage for backup
4. Privacy Protection
Protect sensitive information:- Don’t log detailed request content
- Enable log encryption
- Control log access permissions
- Regularly clean up old logs
Related Resources
- Token Management - Learn how to manage API tokens
- Insufficient Balance - Handle balance issues
- API Reference - View API documentation
- Pricing Description - Understand pricing mechanism