Learn how to send, filter, and analyze logs from your applications using Reasonable.
Reasonable supports standard log levels to help you categorize and filter your logs based on their severity and importance.
| Level | Description | When to use |
|---|---|---|
| debug | Detailed information for debugging | During development or when troubleshooting issues |
| info | General information about system operation | For normal application events like user actions, successful operations |
| warn | Warning conditions that might need attention | For non-critical issues that don't prevent the application from working |
| error | Error conditions that need immediate attention | For errors that prevent a function from working correctly |
| fatal | Critical errors that cause the application to crash | For severe errors that prevent the application from continuing to run |
If you don't specify a log level, Reasonable will default to the "info" level.
Here's how to send logs to Reasonable using our SDKs:
// Basic logging
reasonable.debug('Debugging information');
reasonable.info('User logged in', { userId: '123' });
reasonable.warn('API rate limit approaching', { endpoint: '/api/users', remaining: 10 });
reasonable.error('Failed to process payment', { orderId: '456', error: 'Invalid card' });
reasonable.fatal('Database connection lost', { database: 'users' });
// Logging with context
const orderContext = reasonable.withContext({ orderId: '789' });
orderContext.info('Order created');
orderContext.info('Payment processed');
orderContext.info('Order shipped');
// Logging with tags
reasonable.info('User registered', { userId: '123' }, { tags: ['user', 'registration'] });
// Logging with a timestamp
reasonable.info('Event occurred', {}, { timestamp: new Date('2023-01-01T12:00:00Z') });Structured logging allows you to include additional context with your logs, making them more useful for debugging and analysis.
// Simple structured log
reasonable.info('User registered', {
userId: '123',
email: 'john@example.com',
plan: 'pro',
referrer: 'google'
});
// Structured log with nested objects
reasonable.info('Order completed', {
order: {
id: '456',
amount: 99.99,
currency: 'USD',
items: [
{ id: '1', name: 'Product A', price: 49.99, quantity: 1 },
{ id: '2', name: 'Product B', price: 24.99, quantity: 2 }
]
},
customer: {
id: '123',
name: 'John Doe',
email: 'john@example.com'
},
shipping: {
method: 'express',
address: {
street: '123 Main St',
city: 'New York',
state: 'NY',
zip: '10001'
}
}
});Reasonable provides powerful search and filtering capabilities to help you find the logs you need.
You can use the following syntax to search and filter your logs:
| Syntax | Description | Example |
|---|---|---|
| field:value | Search for logs where the field equals the value | level:error |
| field:"value with spaces" | Search for logs where the field equals the value with spaces | message:"user logged in" |
| field:>value | Search for logs where the field is greater than the value | order.amount:>100 |
| field:<value | Search for logs where the field is less than the value | order.amount:<50 |
| field:value1 OR field:value2 | Search for logs where the field equals value1 or value2 | level:error OR level:fatal |
| field:value1 AND field:value2 | Search for logs where the field equals value1 and value2 | level:error AND service:api |
| field:*value* | Search for logs where the field contains the value | message:*error* |
| -field:value | Search for logs where the field does not equal the value | -level:debug |
level:error - Find all error logsuserId:123 - Find all logs for a specific usermessage:*payment* - Find all logs with "payment" in the messagelevel:error AND service:api - Find all error logs from the API servicetimestamp:>2023-01-01 - Find all logs after January 1, 2023level:error OR level:fatal - Find all error or fatal logs-level:debug - Exclude debug logsReasonable retains your logs based on your subscription plan:
| Plan | Retention Period |
|---|---|
| Free | 7 days |
| Pro | 30 days |
| Enterprise | Custom (up to 1 year) |
Now that you understand how to work with logs in Reasonable, you might want to explore these related topics:
Learn how to set up alerts to get notified when important events occur in your logs.
Create custom dashboards to visualize your log data and metrics.
Learn how to use the Reasonable API directly for advanced use cases.
Explore our SDKs for different programming languages and frameworks.