ServerOps.ggbeta
Server OwnersFiveM / RedM

Player logs

Log player events from your FiveM or RedM server to ServerOps.

Player logs

This guide adds structured logging to your FiveM or RedM server. Every time a player connects, disconnects, gets kicked, or triggers a custom event, a log entry is sent to ServerOps. You can then search and filter those logs from your dashboard.

Logs is currently in early access. The endpoint is live and accepting data, but the dashboard search UI is coming soon.

Before you start

Setting up your token

If you followed the screenshots guide, you already have this in your server.cfg. If not, add it:

set serverops_token "so_live_..."

Creating the logging resource

Create resources/serverops-logs/ with two files:

fxmanifest.lua

fx_version 'cerulean'
game 'gta5'

server_scripts { 'server.lua' }

server.lua

local TOKEN = GetConvar("serverops_token", "")
local API_URL = "https://api.serverops.gg/v1/logs"

-- Sends a log entry to ServerOps.
-- level: "info", "warn", or "error"
-- message: short description of what happened
-- meta: table of extra data (player name, steam ID, etc.)
local function SendLog(level, message, meta)
    local body = json.encode({
        level = level,
        message = message,
        meta = meta or {}
    })

    PerformHttpRequest(API_URL, function(statusCode, responseBody)
        if statusCode ~= 201 then
            print("[ServerOps] Log failed (" .. statusCode .. "): " .. tostring(responseBody))
        end
    end, "POST", body, {
        ["Authorization"] = "Bearer " .. TOKEN,
        ["Content-Type"] = "application/json"
    })
end

-- Log player connections
AddEventHandler("playerConnecting", function(playerName, setKickReason, deferrals)
    local src = source
    SendLog("info", "Player connecting", {
        name = playerName,
        serverId = src,
        identifiers = GetPlayerIdentifiers(src)
    })
end)

-- Log player disconnections
AddEventHandler("playerDropped", function(reason)
    local src = source
    SendLog("info", "Player disconnected", {
        name = GetPlayerName(src),
        serverId = src,
        reason = reason
    })
end)

-- Export the function so other resources can use it
exports("SendLog", SendLog)

Enable the resource

Add to server.cfg:

ensure serverops-logs

Logging from your other scripts

Once the resource is running, any other resource on your server can send a log by calling:

exports["serverops-logs"]:SendLog("info", "Player banned", {
    name = GetPlayerName(source),
    reason = banReason,
    bannedBy = GetPlayerName(adminId)
})

Suggested events to log

Here are common events server owners find useful to track:

EventLevelWhat to include in meta
Player bannedwarnPlayer name, ban reason, admin name
Player kickedwarnPlayer name, kick reason
Staff actioninfoAdmin name, action taken, target player
Cash transactioninfoPlayer name, amount, new balance
Vehicle spawnedinfoPlayer name, vehicle model
Report submittedinfoReporter name, reported player, reason

Example: adding a ban log to your existing ban script

Find the part of your ban script that executes the ban, and add a log call before it:

-- Your existing ban code (example):
DropPlayer(targetId, "You have been banned: " .. reason)
-- Add this line:
exports["serverops-logs"]:SendLog("warn", "Player banned", {
    player = GetPlayerName(targetId),
    reason = reason,
    bannedBy = GetPlayerName(source)
})

Viewing your logs

Logs appear in your dashboard under the Logs section. You can filter by level, search by message, and view the full metadata for each entry.

On this page