All Articles/Logging

Understanding Log Levels and When to Use Each

A practical guide to debug, info, warn, error, and fatal log levels.


The Five Log Levels

Lognitor supports five log levels, from least to most severe:

LevelWhen to Use
debugDetailed diagnostic information. Use during development or when debugging specific issues. Not recommended for production unless investigating a problem.
infoNormal operational events. Server started, user signed up, order created, request completed. The most commonly used level.
warnSomething unexpected but not broken. Rate limit approaching, deprecated API used, slow query detected, retry succeeded.
errorSomething failed. Payment declined, API call timeout, database connection lost. The operation did not complete as expected.
fatalThe application cannot continue. Database corrupted, out of memory, critical config missing. Usually followed by a shutdown.

Examples

JavaScript
Lognitor.debug('Cache miss', { metadata: { key: 'user:123' } });
Lognitor.info('Order created', { metadata: { orderId: 'ord_456', total: 99.99 } });
Lognitor.warn('Rate limit at 85%', { metadata: { usage: 850, limit: 1000 } });
Lognitor.error('Payment failed', { error: new Error('Card declined') });
Lognitor.fatal('Database corrupted, shutting down');

Filtering by Level

Use the minLevel config option to control which levels are sent:

JavaScript
Lognitor.init({
  apiKey: 'your-key',
  minLevel: 'info', // Drops debug logs, sends info and above
});
Production recommendation

Set minLevel: 'info' in production. Enable debug only when investigating specific issues to avoid log volume spikes.