Terug naar blog
Guides5 min leestijd

FiveM Server Logging Done Right: Custom Categories, Metadata, and Discord Webhooks

FiveGateway TeamGuides

FiveM Server Logging Done Right: Custom Categories, Metadata, and Discord Webhooks

Every FiveM server generates logs. The problem is that most of those logs are useless noise buried in a server console that nobody reads. Structured logging changes that by giving every log entry a category, metadata fields, and a destination - so the right information reaches the right person at the right time.


The Problem with Console Logs

Your FiveM server dumps everything into one stream: resource starts, player connections, script errors, and print statements from your custom code. It all lands in the same console with no filtering, no search, and no history beyond what your host keeps.

When something goes wrong - a player exploiting a vehicle spawner, a money dupe, staff abuse - you scroll through thousands of lines hoping to find the one print statement that matters. If the server restarted since then, those logs are gone. There is no way to filter by event type, link an entry to a specific player, or route events to a Discord channel.

Why this matters: Without structured logs, investigating incidents takes hours instead of seconds - and some evidence disappears entirely.


What Structured Logging Actually Means

Structured logging means every log entry has defined fields instead of being a raw string. Instead of printing "Player John spawned a vehicle," you log an event with a category, a player reference, a vehicle model field, and a location.

This makes logs searchable. Want to see every vehicle spawn by a specific player in the last 24 hours? Filter by category and player. Need to know how many times a particular vehicle model was spawned this week? Filter by field value and count.

In FiveGateway, structured logs are built around categories. Each category defines what fields a log entry contains, how it displays in the dashboard, and where it gets forwarded. Check the full logging and moderation features to see what is included on each plan.

Why this matters: Structured logs turn raw console noise into a searchable, filterable audit trail for your server.


Creating a Log Category in FiveGateway

A log category defines a type of event you want to track. To create one in the FiveGateway dashboard:

  1. Name the category. Use a kebab-case identifier like vehicle-spawns or player-reports. This is what your scripts reference when sending logs.
  2. Pick a color. Each category gets a color label so you can visually distinguish event types in the log viewer.
  3. Define fields. Add the data fields each log entry should contain. Every field has three properties:
    • Key - the identifier your script uses (e.g. player, vehicle, location)
    • Display name - the human-readable label shown in the dashboard (e.g. "Player Name", "Vehicle Model")
    • Type - choose text, number, or player. The player type automatically links the entry to a player profile in FiveGateway.

Common categories include vehicle spawns, money transactions, staff actions, player reports, and ban events.

Why this matters: Custom categories let you organize logs by event type instead of dumping everything into one unreadable stream.


Sending a Log from a Lua Script

Once your category exists, sending a log entry from any server-side Lua script takes one export call:

exports['fivegateway']:log('vehicle-spawns', {
    player = GetPlayerName(source),
    vehicle = vehicleModel,
    location = coords
})

The first argument is the category name. The second is a table with keys matching the fields you defined in the dashboard. FiveGateway validates the data, timestamps it, and stores it automatically.

Add this call anywhere in your scripts - event handlers, command callbacks, or resource logic. Every call creates a new searchable log entry. No extra dependencies or logging frameworks to install.

Why this matters: One line of Lua gives you a permanent, searchable log entry instead of a disposable print statement.


Forwarding Logs to Discord with Webhooks

Every log category can have a Discord webhook URL attached. When a new log entry arrives in that category, FiveGateway automatically posts a formatted embed to your Discord channel.

To set it up:

  1. Create a webhook in your Discord server (Server Settings > Integrations > Webhooks).
  2. Copy the webhook URL.
  3. Paste it into the category's webhook field in the FiveGateway dashboard.

Every new log entry posts to Discord with all its fields displayed in a clean embed. Your staff sees events in real time without opening the dashboard.

Route different categories to different channels - vehicle spawns to a moderation channel, money transactions to an admin-only channel, player reports to a staff inbox.

Why this matters: Discord webhooks bring your logs to where your team already communicates, so nothing gets missed.


Controlling Access with Role-Based Permissions

Not every staff member needs access to every log category. FiveGateway lets you restrict which staff roles can view specific categories from the dashboard.

Your moderators might see player reports and chat logs, while financial transaction logs stay visible only to senior admins. Set this per category by selecting which roles have read access. Staff members only see the categories assigned to their role.

Why this matters: Role-based log access keeps sensitive data visible only to the people who need it.


Log Retention by Plan

FiveGateway stores your log history based on your plan:

Plan Retention
Starter 7 days
Pro 30 days
Premium 90 days

Older entries are automatically removed after the retention window. Upgrading your plan extends the window for all existing and future logs.


Start Logging the Right Way

Console prints are fine for debugging during development. For a live server with real players and real staff, you need logs that are searchable, structured, and routed to the right people.

Set up your first log category in minutes. No complex configuration, no external logging tools, no Lua frameworks to install.

Open the dashboard at my.fivegateway.com →

Compare plans and retention limits on the pricing page.


Stay Updated

Follow development updates, feature announcements, and behind-the-scenes progress: