Skip to main content

How to Set Log Policies for Operating a coturn Server

Purpose

  • Logging to a separate file instead of syslog
  • Logs older than a certain period are automatically deleted.(예시 : 7일)

Creating the /var/log/turn directory

  1. /var/log/pathturnCreate a directory with the name
  2. chown turnserver:turnserver turnto the directory with a commandturnserverChanged for user accessibility

turn server config change

Change Logging Level

  1. /etc/turnserver.confOpen with editor
  2. If you scroll down through the content,#verboseYou will see a line that saysCaution:vis lowercaseverboseIm, since there are uppercase letters, you need to distinguish them well.)
  3. #Uncomment by deleting
  4. below thatVerboseSaid in uppercaseVThere should be something that starts with 로.#Add and comment out
  • verbose: General Debugging
  • Verbose(VUppercase) : Packet-Level Detailed Analysis**(It is recommended to disable in the production environment)**

Standard Output Prohibited

  1. /etc/turnserver.confOpen with editor
  2. If you scroll down through the content,#no-stdout-logYou will see a line that says.
  3. here#Remove to uncomment
  • no-stdout-log: If this is commented outlog-fileIn addition to the options, standard output is also processed concurrently.syslogWowlog-fileBoth logs are accumulated.

Change Log Storage Path

  1. /etc/turnserver.confOpen with editor
  2. If you scroll down through the content,syslogYou will see a line that says.
  3. syslogthe textlog-file=/var/log/turn/turn.logchanged as follows
  4. below line#simple-logText exists
  5. #simple-login front of#Remove to uncomment
  • log-file: Save log to the specified path
  • simple-log: Prevent the PID from being attached to the log file name, which results inlogrotateIt has become easier to specify patterns in __PH_0__.

로깅 수준 변경, 표준 출력 금지, log 저장 경로 변경Save after completion


Setting Log Management Cycle Using Linux logrotate

  1. /etc/logrotate.dpathturnCreate a file called
  2. editorturnFile Access
  3. Save after entering the log policy details as shown below.
/var/log/turn/turn.log {
daily
rotate 7
missingok
compress
delaycompress
notifempty
create 640 turnserver turnserver
postrotate
/usr/bin/pkill -HUP turnserver > /dev/null 2>&1 || true
endscript
}
  • daily= Save frequency: Daily (weekly, monthly possible)
  • rotate 7= Number of stored items: 7 (Logs older than 7 days will be deleted)
  • missingok= Ignore errors even if the file is missing
  • compress= Compressing Past Logs (gzip, if the storage period is set to daily, compression starts from the 2nd day's log)
  • delaycompress= Delay compression until the next cycle (to prevent file write conflicts)
  • notifempty= No rotation if there are no log entries
  • create 640 turnserver turnserver= Create File Permissions and Owner Assignment
  • /usr/bin/pkill -HUP turnserver > /dev/null 2>&1 || true= Send a signal (SIGHUP) to Coturn to reopen the log file

Restarting the service to apply the changed settings

  1. sudo systemctl restart coturnRestarting the turn service with a command

Check if the log is saved correctly

  1. /var/log/turn/turn.logA file has been created in the path.tail -fCheck if the log is being loaded when confirmed with commands such as __PH_0__.