Now that you have installed Loki and Grafana, you can using ox_lib to send logs to Loki.
ox_lib.zip
from hereox_lib.zip
and copy the ox_lib
folder to your server’s resources
folderensure ox_lib
in your server.cfgYou will get all the convars that are needed for ox_lib at the end of the installation process. Add them to your server.cfg. They will look like the following:
set ox:logger "loki"
set loki:user "admin"
set loki:key "supersecurepassword"
set loki:protocol "https"
set loki:endpoint "loki.fivem-loki-demo.illenium.gg"
Add ox_lib
to your resource via fxmanifest.lua:
shared_script '@ox_lib/init.lua'
Then you can send logs from the server-side using lib.logger
like so:
lib.logger(source, event, message, ...)
-- Example
lib.logger(-1, 'CreateVehicle', "A vehicle was created")
Refer to the detailed documentation about the function here