What is CodeIgniter 4's Logging?
Why Interviewers Ask This
This is a classic screening question for CodeIgniter roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.
Answer
CodeIgniter 4 has a PSR-3 compatible logging system. Configure in app/Config/Logger.php. Default log levels (in order of severity): emergency, alert, critical, error, warning, notice, info, debug. Set minimum threshold: $threshold = 4 (only log warnings and above). Log a message: log_message("error", "Something went wrong: {message}", ["message" => $e->getMessage()]). Or via the service: service("logger")->warning("Low disk space"). Handlers: FileHandler (logs to writable/logs/), ErrorlogHandler (PHP error log), or custom handlers implementing the PSR-3 LoggerInterface. Use the debug toolbar to view logs during development. In production, set a higher threshold to avoid writing excessive logs.
Pro Tip
If you're unsure about a detail, say so honestly and explain your reasoning. Interviewers respect candidates who can think through uncertainty rather than bluffing.