Log Filtering

Filter logs based on various criteria

Filter logs based on level, status, or HTTP method using Logixlysia's flexible filtering system.

Basic Usage

logixlysia({
  config: {
    logFilter: {
      level: ['ERROR', 'WARNING'],
      status: [500, 404],
      method: 'GET'
    }
  }
})

Filter Types

By Log Level

logFilter: {
  level: ['ERROR', 'WARNING'] // Only log ERROR and WARNING messages
}

Available levels: ERROR, WARNING, INFO, DEBUG

By HTTP Status

logFilter: {
  status: [500, 404] // Only log 500 and 404 responses
}

By HTTP Method

logFilter: {
  method: 'GET' // Only log GET requests
}

Or multiple methods:

logFilter: {
  method: ['POST', 'PUT']
}

Combined Filters

logFilter: {
  level: ['ERROR'],
  status: [500],
  method: ['POST', 'PUT']
}

Environment-Specific Filters

logFilter: process.env.NODE_ENV === 'production' 
  ? { level: ['ERROR'] }
  : null // Log everything in development

Best Practices

  • Production: Filter to essential logs only (errors and warnings)
  • Development: Log everything for debugging
  • Security: Filter sensitive routes and avoid logging sensitive data
  • Performance: Use simple filters in production

On this page