วิธีดู Server Console และ Log ใน txAdmin FiveM หา Error และแก้ปัญหา Server ให้ตรงจุด

การดู Server Console และ Log ใน txAdmin เป็นหนึ่งในทักษะสำคัญที่สุดสำหรับผู้ดูแล FiveM Server เพราะเมื่อ Server เปิดไม่ได้, Resource Error, Database เชื่อมต่อไม่ได้, Player เข้าไม่ได้ หรือ Server Crash ข้อมูลต้นเหตุส่วนใหญ่มักปรากฏอยู่ใน Console หรือ Log

txAdmin มีระบบหลักที่ควรรู้ 3 ส่วน ได้แก่

Live Console
FXServer Console Log
Server Activity Log

นอกจากนี้ยังมี Admin Log สำหรับตรวจว่า Admin คนใดทำ Action อะไร เช่น Restart Server, Ban, Warn, เปลี่ยน Settings หรือส่งคำสั่งผ่าน Live Console

วิธีวิเคราะห์ที่ถูกต้องคือ

เกิดปัญหา
↓
เปิด Live Console
↓
หา Error แรก
↓
ดู Resource/Database ที่เกี่ยวข้อง
↓
ตรวจ Log ย้อนหลัง
↓
แก้ Root Cause
↓
Restart เฉพาะสิ่งที่จำเป็น
↓
ตรวจ Console อีกครั้ง

ไม่ควรแก้ FiveM Server ด้วยการ Restart ซ้ำ ๆ โดยไม่อ่านข้อความ Error

① Server Console คืออะไร

Server Console คือหน้าที่แสดงข้อมูลจาก FXServer แบบ Real-time

สามารถเห็นข้อความ เช่น

Starting resource...
Started resource...
Connecting...
Error...
Warning...
SCRIPT ERROR...

รวมถึงข้อความจาก Resources ที่ใช้ print() หรือระบบ Logging ของตัวเอง

จึงเป็นจุดแรกที่ควรเปิดเมื่อ Server มีปัญหา

② Live Console ใน txAdmin คืออะไร

txAdmin มี Live Console สำหรับดู Output ของ FXServer ผ่าน Browser

ข้อดีคือไม่จำเป็นต้อง Remote Desktop ไปดูหน้าต่าง FXServer ตลอดเวลา

สามารถใช้ Browser เพื่อตรวจ

  • Server Startup

  • Resource Startup

  • Errors

  • Warnings

  • Player Connections

  • Console Commands

ได้จาก txAdmin

③ วิธีเข้า Live Console

Login txAdmin

จากนั้นเปิดหน้า

Live Console

Admin ต้องมี Permission

console.view

จึงจะดู Console ได้

ถ้าเปิดหน้า Console ไม่ได้ให้ตรวจ Permission ก่อน

④ console.view คืออะไร

Permission

console.view

อนุญาตให้ Admin ดู Live Console

แต่ไม่ได้หมายความว่าสามารถพิมพ์ Command ได้

เหมาะกับ

  • Developer

  • Technical Support

  • Senior Admin

ที่ต้องตรวจ Error โดยไม่จำเป็นต้องควบคุม Server

⑤ console.write คืออะไร

Permission

console.write

ใช้สำหรับส่ง Command เข้า Live Console

ตัวอย่าง

restart my_resource

หรือ

ensure my_resource

ผู้ที่มี console.view อย่างเดียวจะดู Console ได้ แต่ไม่ควรสามารถ Execute Commands ผ่าน Console

⑥ ทำไมต้องแยก console.view กับ console.write

เพราะ Console Commands มีอำนาจสูง

Resource ที่ติดตั้งเพิ่มอาจสร้าง Commands สำหรับ

  • เงิน

  • Player

  • Inventory

  • Server

  • Database

  • Resource Management

ดังนั้น Staff ที่ต้อง Debug อย่างเดียวสามารถได้รับ

console.view

โดยไม่ต้องได้รับ

console.write

ช่วยลดความเสี่ยงจากการพิมพ์ Command ผิด

⑦ Server Log ต่างจาก Console อย่างไร

Console เน้น Output ที่กำลังเกิดขึ้นจาก FXServer

ส่วน Server Activity Log ของ txAdmin เน้นเหตุการณ์ภายใน Server เช่น

  • Player Join

  • Player Leave

  • Player Death

  • Chat

  • Explosions

  • Menu Events

  • Commands

จึงมีประโยชน์คนละแบบ

⑧ txAdmin Log คืออะไร

txAdmin Log หรือ Admin Log ใช้บันทึก Action ด้านการบริหาร เช่น

  • Restart Server

  • Ban

  • Warn

  • Settings Change

  • Live Console Input

  • Administrative Actions อื่น

เหมาะสำหรับตรวจว่า

ใคร
ทำอะไร
เมื่อไร

ในระบบ Admin

⑨ Permission ดู txAdmin Log คืออะไร

ใช้

txadmin.log.view

Permission นี้แยกจากการดู Server Log

ดังนั้น Staff สามารถถูกอนุญาตให้ดู Server Activity ได้โดยไม่จำเป็นต้องดู Administrative Log ทั้งหมด

⑩ Permission ดู Server Log คืออะไร

ใช้

server.log.view

สำหรับดู Server Logs

เหมาะกับ

  • Senior Moderator

  • Developer

  • Server Manager

ที่ต้องตรวจพฤติกรรมและเหตุการณ์ย้อนหลัง

⑪ Server Log เก็บ Player Join หรือไม่

เก็บ

txAdmin Server Log สามารถบันทึกเหตุการณ์ประเภท

Player Join
Player Leave
Player Death
Chat
Explosion
Menu Event
Commands

จึงมีประโยชน์มากเวลาเกิด Report แล้วต้องตรวจเหตุการณ์ย้อนหลัง

⑫ FXServer Console Log เก็บอะไร

FXServer Console Log เก็บข้อมูลจาก

stdin
stdout
stderr

ของ FXServer

พูดง่าย ๆ คือสิ่งที่ปรากฏใน Console จะถูกบันทึกเป็น Log สำหรับตรวจย้อนหลัง

รวมถึง Command ที่ถูกส่งจาก Live Console

⑬ Command จาก Live Console ถูกบันทึกไหม

ถูกบันทึก

ใน FXServer Console Log การป้อนคำสั่งผ่าน Live Console จะถูกแสดงโดยมี Prefix ในลักษณะ

> command

และ txAdmin ยังมี Admin Logging สำหรับ Action ที่เกี่ยวข้องด้วย

จึงช่วยตรวจสอบได้ว่าเกิดอะไรขึ้นก่อน Server มีปัญหา

⑭ Log อยู่ที่ไหน

เอกสาร txAdmin ระบุ Persistent Logs อยู่ภายใต้โครงสร้าง

txData/<profile>/logs/

สำหรับระบบที่ใช้ Profile Layout ดังกล่าว

ภายในมี Log หลายประเภทตาม Configuration ของ txAdmin

ดังนั้นการ Backup txData ยังมีประโยชน์ต่อการเก็บประวัติการวิเคราะห์ Server ด้วย

⑮ Log อยู่ถาวรหรือหายเมื่อปิด Server

txAdmin รองรับ Persistent Logging

หมายความว่า Log ถูกเขียนเป็น File และมีระบบ Log Rotation

จึงสามารถกลับมาตรวจเหตุการณ์ย้อนหลังได้หลัง Server Restart

นี่ต่างจากการดูข้อความบน Console อย่างเดียวแล้วปิดหน้าต่างทิ้ง

⑯ Log Rotation คืออะไร

Log Rotation คือระบบแบ่ง Log เป็นไฟล์ตามช่วงเวลาและควบคุมจำนวน/ขนาดไฟล์

แทนที่จะมีไฟล์เดียวใหญ่หลายสิบ GB

แนวคิดคือ

วันนี้
→ log file 1

พรุ่งนี้
→ log file 2

วันต่อไป
→ log file 3

แล้ว txAdmin จัดการไฟล์เก่าตามค่าที่กำหนด

⑰ FXServer Console Log เก็บนานแค่ไหน

ค่าเริ่มต้นในเอกสาร txAdmin ปัจจุบันระบุ FXServer Console Log หมุนไฟล์ทุกวัน และเก็บจำนวนไฟล์ตาม Default Rotation Policy ที่กำหนดไว้

ค่าเหล่านี้สามารถปรับผ่าน Logger Configuration ได้

ดังนั้น Server ที่ต้องเก็บ Log ระยะยาวควรวาง Policy ให้เหมาะกับพื้นที่ Disk

⑱ Server Activity Log เก็บนานแค่ไหน

Server Log ก็ใช้ระบบ Daily Rotation ตามค่า Default ปัจจุบัน และมีข้อจำกัดด้านจำนวนไฟล์/ขนาดตามระบบ Logging

หาก Server มี Player จำนวนมาก Log สามารถโตเร็วมาก

ควรตรวจ Disk Usage เป็นระยะ

⑲ Admin Log ต่างจากอีกสอง Log อย่างไร

Admin Log เน้น Actions ของระบบบริหาร

ตัวอย่าง

Admin A Restart Server
Admin B Ban Player
Admin C Warn Player
Admin D Change Setting
Admin E Execute Console Command

ดังนั้นเหมาะสำหรับ Audit ทีมงานมากกว่า Debug Script โดยตรง

⑳ ควรดูอะไรเป็นอันดับแรกเมื่อ Server เปิดไม่ได้

เปิด Live Console แล้วดูตั้งแต่ช่วง Startup

ค้นหาข้อความ เช่น

ERROR
SCRIPT ERROR
Failed
Couldn't
Unable
Missing
Denied

โดยเฉพาะ Error แรกที่เกิดขึ้น

เพราะ Error จำนวนมากด้านล่างอาจเป็นผลต่อเนื่องจาก Error แรก

㉑ ทำไมต้องหา Error แรก

ตัวอย่าง

Resource A
→ Database connection failed

จากนั้น

Resource B
→ export not found
Resource C
→ nil value
Resource D
→ framework unavailable

Error B, C และ D อาจเป็นผลจาก Resource A ไม่ Start

ถ้าแก้ Error ท้ายสุดก่อนจะเสียเวลา

㉒ SCRIPT ERROR หมายถึงอะไร

ข้อความ

SCRIPT ERROR

มักหมายถึง Code ใน Resource เกิด Runtime Error

ให้ดูบรรทัดถัดไป เช่น

resource name
file name
line number
error message

ข้อมูลเหล่านี้ช่วยระบุ Script ที่มีปัญหา

㉓ ตัวอย่าง Lua Error

อาจพบข้อความคล้าย

SCRIPT ERROR: @my_resource/server.lua:42:
attempt to index a nil value

ให้แยกเป็น

Resource = my_resource
File = server.lua
Line = 42
Problem = nil value

จากนั้นจึงตรวจ Code บริเวณ Line นั้น

㉔ อย่าดูเฉพาะคำว่า Error

บางปัญหาแสดงเป็น

Warning
Failed
Timeout
Refused
Denied
Deprecated

ไม่ได้ขึ้นคำว่า ERROR เสมอไป

จึงควรอ่านข้อความรอบ ๆ เหตุการณ์ด้วย

㉕ Database Error ดูอย่างไร

ปัญหา Database อาจมีข้อความเกี่ยวกับ

MySQL
MariaDB
Connection
Query
Table
Column
Duplicate
Access denied
Timeout

เมื่อพบให้ตรวจ

  • Database Running

  • Connection String

  • Username

  • Password

  • Database Name

  • SQL Schema

  • Query

ไม่ควร Restart FXServer ซ้ำอย่างเดียว

㉖ Access denied for user หมายถึงอะไร

ถ้า Database ขึ้นในลักษณะ

Access denied for user

ให้สงสัย

  • Username ผิด

  • Password ผิด

  • Host Permission ผิด

  • Database User ไม่มีสิทธิ์

ไม่ใช่ปัญหา FiveM Artifact โดยตรง

㉗ Table doesn't exist หมายถึงอะไร

ข้อความลักษณะ

Table 'database.users' doesn't exist

หมายถึง Resource กำลัง Query Table ที่ไม่มี

ให้ตรวจ

  • Import SQL แล้วหรือไม่

  • Database ถูกตัวหรือไม่

  • Framework Version ตรงกับ SQL หรือไม่

อย่าแก้ด้วยการ Restart Resource ซ้ำ

㉘ Unknown column หมายถึงอะไร

ข้อความ

Unknown column

มักบ่งบอกว่า Database Schema ไม่ตรงกับ Resource Version

เช่น Script รุ่นใหม่ต้องการ Column ใหม่ แต่ Database ยังเป็น Schema เก่า

ต้องตรวจ Migration/SQL Update ของ Resource

㉙ Resource ไม่ Start ดู Console อย่างไร

มองหา Resource Name

ตัวอย่าง

my_inventory

แล้วดูข้อความก่อนและหลัง

อาจพบ

Couldn't start resource
Missing dependency
Failed to load script
Manifest error

จากนั้นแก้ตามข้อความจริง

㉚ Missing dependency คืออะไร

Resource A อาจต้องใช้ Resource B

ตัวอย่าง

inventory
↓
framework
↓
database library

ถ้า Dependency ไม่ Start Resource ด้านบนอาจ Error ตาม

ให้ตรวจลำดับ ensure และ Resource ที่ต้องใช้ก่อน

㉛ หา Resource จาก Console Search ได้ไหม

txAdmin Live Console รองรับ Search

จึงสามารถค้นหา

resource_name

หรือ Keyword เช่น

error

ได้

มีประโยชน์มากเมื่อ Console มีข้อความหลายพันบรรทัด

㉜ Command History มีไหม

Live Console ของ txAdmin รองรับ Command History

ช่วยดู Command ที่เคยส่งและเรียกคำสั่งเดิมได้สะดวกขึ้น

แต่ Production Server ควรตรวจ Command ก่อน Execute ซ้ำทุกครั้ง

โดยเฉพาะ Command ที่มี Player ID หรือ Resource Name

㉝ Player เข้าไม่ได้ควร Search อะไร

เริ่มจากชื่อ Player หรือช่วงเวลาที่ Player Connect

ดูข้อความเกี่ยวกับ

Connecting
Deferring
Dropped
Identifier
License
Endpoint
Timeout

จากนั้นดู Server Activity Log ประกอบ

จะช่วยแยกว่า Player เข้ามาถึง FXServer หรือยัง

㉞ Player Join ถูกบันทึกใน Server Log อย่างไร

txAdmin ใช้รูปแบบ Identifier ภายใน Log เพื่อช่วยเชื่อม Event ของ Player คนเดียวกัน

เมื่อค้นหา Entry ของ Player Join จะสามารถตาม Event อื่นของ Player นั้นใน Server Execution เดียวกันได้ง่ายขึ้น

เหมาะกับการสอบสวน Report ย้อนหลัง

㉟ Player หลุดบ่อยดูอะไร

หา Event

disconnect
drop
timeout
crash

แล้วดูเวลาที่เกิด

หาก Player หลายคนหลุดพร้อมกัน ให้สงสัย Server/Network

ถ้ามี Player คนเดียวหลุด อาจเป็น Client หรือ Connection ของ Player นั้น

ต้องดูบริบททั้งหมด

㊱ Server Crash ดูตรงไหน

หลัง Crash ให้ตรวจ

  • FXServer Console Log

  • txAdmin Admin Log

  • Server Log

  • Crash Information ที่ระบบสร้าง

ดูช่วงก่อน Crash ไม่กี่วินาทีหรือไม่กี่นาที

โดยเฉพาะ Resource ที่เพิ่ง

start
restart
update

ก่อนเกิดเหตุ

㊲ txAdmin Restart Server อัตโนมัติจะมี Log ไหม

มี Administrative Logging เกี่ยวกับ Server Restarts รวมถึง Automated Actions บางประเภท

ดังนั้นสามารถใช้ Log ช่วยแยกว่า

Admin Restart

หรือ

ระบบ Restart จาก Monitoring/Schedule

เกิดขึ้นช่วงใด

㊳ วิธีตรวจว่าใครพิมพ์ Console Command

txAdmin มี Action Logging และ Event สำหรับคำสั่งที่ส่งผ่าน Live Console

ข้อมูลสามารถระบุ Admin Username ที่ส่ง Command ได้

จึงเป็นอีกเหตุผลที่ไม่ควรให้ Staff หลายคนแชร์ Account เดียวกัน

㊴ Staff แชร์ Account มีผลกับ Log อย่างไร

ถ้า 5 คนใช้

admin

Account เดียว

Log จะบอกได้เพียงว่า

admin

ทำ Action

แต่ไม่รู้ว่าเป็นบุคคลใดจริง

ดังนั้นควรใช้

admin_a
admin_b
developer_c

แยก Account เสมอ

㊵ ดู Ban/Warn จาก Log ได้ไหม

Admin Log มีข้อมูลเกี่ยวกับ Ban และ Warn

นอกจากนี้ txAdmin ยังเก็บ Action ประเภท Warn/Ban/Whitelist ไว้ใน Player Database ของระบบด้วย

ดังนั้นไม่ได้พึ่ง Log File อย่างเดียวสำหรับข้อมูลลงโทษผู้เล่น

㊶ Chat ถูกเก็บใน Server Log ไหม

Server Activity Log รองรับ Chat Messages

ทำให้สามารถใช้ตรวจเหตุการณ์ย้อนหลังได้

แต่ Server Owner ควรกำหนดนโยบายการเก็บและเข้าถึง Log ให้เหมาะสมกับ Community และข้อกำหนดด้าน Privacy ที่เกี่ยวข้อง

㊷ Explosion ถูก Log ได้ไหม

txAdmin Server Activity Log รองรับ Explosion Events

จึงช่วยตรวจเหตุการณ์ผิดปกติบางประเภทได้

แต่ Log เพียงอย่างเดียวไม่ควรถูกใช้ตัดสินการโกงโดยไม่มีบริบทหรือหลักฐานประกอบ

㊸ Custom Command เก็บ Log ได้ไหม

txAdmin รองรับการเพิ่ม Logging สำหรับ Custom Client Commands

Developer สามารถ Trigger Event

txaLogger:CommandExecuted

เพื่อส่งข้อมูล Command เข้า Server Logging

เหมาะกับ Server ที่มี Custom Admin หรือ Gameplay Commands สำคัญ

㊹ ต้อง Log ทุก Command หรือไม่

ไม่จำเป็น

ควรเลือกเฉพาะ Command ที่มีประโยชน์ด้าน

  • Security

  • Moderation

  • Economy

  • Administration

  • Troubleshooting

การ Log ทุก Action แบบละเอียดมากอาจเพิ่ม Noise และ Storage Usage

㊺ Log ใหญ่เกินไปทำอย่างไร

txAdmin รองรับการปรับ Log Rotation

สามารถกำหนดค่าประเภท

interval
maxSize
maxFiles

ตาม Logger Configuration

Server ขนาดใหญ่ควรกำหนด Retention ให้สมดุลระหว่าง

ข้อมูลย้อนหลัง
กับ
พื้นที่ Disk

㊻ ปิด Log บางประเภทได้ไหม

ระบบ Logging ของ txAdmin รองรับการ Disable Log Type ผ่าน Configuration

แต่ Production Server ไม่ควรปิด Log สำคัญโดยไม่มีเหตุผล

เพราะเมื่อเกิด

  • Hack

  • Staff Abuse

  • Crash

  • Data Issue

จะขาดข้อมูลสำหรับวิเคราะห์ย้อนหลัง

㊼ ก่อนแก้ Log Configuration ควรทำอะไร

Backup

txData

ก่อน

โดยเฉพาะก่อนแก้ Config ด้วยมือ

และตรวจ Syntax ให้ถูกต้อง เพราะ JSON Error สามารถสร้างปัญหากับ Configuration ได้

㊽ Checklist วิเคราะห์ Error ด้วย txAdmin

ใช้ลำดับนี้

1. เปิด Live Console
2. ระบุเวลาที่ปัญหาเกิด
3. หา Error แรก
4. หา Resource Name
5. อ่าน File/Line ถ้ามี
6. ตรวจ Dependency
7. ตรวจ Database ถ้าเกี่ยวข้อง
8. Search Resource Name
9. ดู FXServer Console Log ย้อนหลัง
10. ดู Server Activity Log
11. ดู Admin Log ถ้ามีการแก้ Server ก่อนเกิดปัญหา
12. แก้ Root Cause
13. Restart Resource หรือ Server ตามความจำเป็น
14. ดู Console อีกครั้ง
15. ทดสอบ Feature จริง

วิธีนี้แม่นยำกว่าการ Restart ทุกอย่างพร้อมกัน

㊾ ข้อผิดพลาดที่ผู้ดูแล Server ควรเลี่ยง

ไม่ควร

  • เห็น Error แล้ว Restart ทันทีโดยไม่อ่าน

  • ลบ Log เพื่อแก้ Server

  • แจก console.write ให้ Staff ทุกคน

  • แชร์ Root Account

  • ดูเฉพาะ Error บรรทัดสุดท้าย

  • ไม่ตรวจ Database Error

  • ปิด Logging ทั้งหมดเพื่อประหยัด Disk

  • เก็บ Log จน Disk เต็ม

  • เปิดเผย Password/Server Key ที่อาจปรากฏในข้อมูล Debug

  • Copy Log ทั้งหมดลง Public Discord โดยไม่ตรวจข้อมูลสำคัญ

ควรส่งเฉพาะส่วนที่เกี่ยวข้องและปิดบัง Secrets ก่อนแชร์

㊿ สรุปวิธีดู Server Console และ Log ใน txAdmin

สำหรับการดู FiveM Server แบบ Real-time ให้ใช้

Live Console

Admin ที่ต้องการดู Console ต้องมี

console.view

และถ้าต้องส่ง Command ต้องมี

console.write

ส่วน Log สำคัญแบ่งได้เป็น

FXServer Console Log
→ สิ่งที่เกิดใน FXServer Console

Server Log
→ Player/Server Activity

Admin Log
→ การกระทำของ Admin และ txAdmin

Permission สำหรับดู Log แยกเป็น

server.log.view
txadmin.log.view

txAdmin ยังรองรับ Persistent Logging, File Rotation, Live Console Search และ Command History ทำให้สามารถตรวจย้อนหลังได้ว่า Server เกิดอะไรขึ้นก่อน Resource Error, Player หลุด หรือ Server Crash

สำหรับ Production Server comsiam แนะนำให้ใช้ Console เป็นเครื่องมือ Debug หลัก และอ่าน Error ตั้งแต่บรรทัดแรกที่ผิดปกติ ไม่ควรกด Restart Server ซ้ำเพื่อหวังให้ปัญหาหายเอง

อีกเรื่องที่สำคัญคือให้ Staff ใช้ Admin Account แยกกัน เพราะเมื่อมีการ Execute Command, Ban, Warn หรือ Restart Server จะสามารถตรวจย้อนหลังได้ว่า Account ใดเป็นผู้ดำเนินการ

เมื่อจัด Permission, Log Rotation และ Account Management อย่างเหมาะสม ผู้ดูแล FiveM Server ของ comsiam จะสามารถย้อนดูเหตุการณ์และหา Root Cause ได้รวดเร็วกว่าการแก้ปัญหาด้วยการเดาหรือ Restart ทั้ง Server ทุกครั้ง

Comments

Popular posts from this blog

FiveM ยังน่าเล่นไหม? Enhanced เปลี่ยน FiveM แค่ไหน

FiveM คืออะไร เล่นอย่างไร สำหรับมือใหม่ เริ่มต้นตั้งแต่ศูนย์

วิธีตั้ง Admin Permission ด้วย add_ace และ add_principal FiveM แบบละเอียด