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
/var/log/pathturnCreate a directory with the namechown turnserver:turnserver turnto the directory with a commandturnserverChanged for user accessibility
turn server config change
Change Logging Level
/etc/turnserver.confOpen with editor- 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.) #Uncomment by deleting- below that
VerboseSaid in uppercaseVThere should be something that starts with 로.#Add and comment out
verbose: General DebuggingVerbose(VUppercase) : Packet-Level Detailed Analysis**(It is recommended to disable in the production environment)**
Standard Output Prohibited
/etc/turnserver.confOpen with editor- If you scroll down through the content,
#no-stdout-logYou will see a line that says. - 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
/etc/turnserver.confOpen with editor- If you scroll down through the content,
syslogYou will see a line that says. syslogthe textlog-file=/var/log/turn/turn.logchanged as follows- below line
#simple-logText exists #simple-login front of#Remove to uncomment
log-file: Save log to the specified pathsimple-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
/etc/logrotate.dpathturnCreate a file called- editor
turnFile Access - 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 missingcompress= 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 entriescreate 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
sudo systemctl restart coturnRestarting the turn service with a command
Check if the log is saved correctly
/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__.