Settings > Logs - how long the audit log (with API key use) and * the app logs are kept, each its own number of days or forever, and sending * their entries on to a syslog server or SIEM as they are written * (functions/log_forward.php). Saved by edit_log_settings, or * test_log_forward, which saves and sends a test message * (admin/post/settings_logs.php). */ require_once "includes/inc_all_admin.php"; // Read here rather than with every page's settings, so the page still opens before the update that adds them $retention = appLogRetention(); $forward = logForwardSettings(); $audit_size = appLogSize('logs'); $app_size = appLogSize('app_logs'); // The last time sending failed, in the last day $forward_failure = null; if ($forward['enabled']) { $forward_failure = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT app_log_id, app_log_details, app_log_created_at FROM app_logs WHERE app_log_category = '" . escapeSql(LOG_FORWARD_CATEGORY) . "' AND app_log_type = 'error' AND app_log_created_at > NOW() - INTERVAL 1 DAY ORDER BY app_log_id DESC LIMIT 1")); } // What an entry looks like as it is sent - the latest audit log entry, in the format picked $sample_row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT log_id, log_type, log_action, log_description, log_ip, log_user_agent, log_created_at, log_client_id, log_user_id, log_entity_id, user_name, user_email, user_type, client_name FROM logs LEFT JOIN users ON user_id = log_user_id AND log_user_id > 0 LEFT JOIN clients ON client_id = log_client_id AND log_client_id > 0 ORDER BY log_id DESC LIMIT 1")); $samples = []; if ($sample_row) { foreach (array_keys(LOG_FORWARD_FORMATS) as $format) { $samples[$format] = logForwardAuditMessage($sample_row, $format); } } $size_line = function ($size, $url) { if (!$size['count']) { return 'Nothing in it yet.'; } return '' . number_format($size['count']) . ' entr' . ($size['count'] === 1 ? 'y' : 'ies') . ', the oldest from ' . escapeHtml(date('M j, Y', strtotime($size['oldest']))) . '.'; }; // The days field and its keep forever switch, for one log $retention_field = function ($name, $forever_name, $days, $label, $help) { $id = preg_replace('/[^a-z_]/', '', $name); ob_start(); ?>