Configure logging
During the operation of ADCM, logs of different types are created in the files located in the /<data_volume>/log/ directory. Its files and subdirectories contain the following information:
-
adcm.log and adcm_debug.log — records of events and errors arising during the ADCM operation, respectively;
-
nginx/ — the Nginx logs;
-
audit.log — records of the audit events;
-
cron_task.log — information about background tasks that are executed by a task scheduler, for example, erase the data related to objects configurations such as cluster or service;
-
task_runner.err — error messages in case of unsuccessfully launched actions;
-
ldap.log — messages about authentication in ADCM via LDAP;
-
status.log — records of events arising during the Status Server operations;
-
wsgi.log — records of events arising during the uWSGI operations.
The following configuration options that allow you to manage logs and record only the required events to log files are available for the abovementioned log files:
-
Log level configuration.
-
Configuration of the uWSGI logging settings.
-
Log rotation configuration.
Log level configuration can be done for a specific log type. The log level value specified for one type does not affect the other types and is applied during the ADCM launch.
Log level
To configure the log level, you can use special environment variables when creating the container according to the log type:
-
STATUS_LOG_LEVEL
— log level for the Status Server; -
ADCM_LOG_LEVEL
— log level for the Backend Server; -
AUDIT_LOG_LEVEL
— log level for audit.log; -
LDAP_LOG_LEVEL
— log level for ldap.log; -
BACKGROUND_TASKS_LOG_LEVEL
— log level for the background jobs; -
TASK_RUNNER_LOG_LEVEL
— log level for task_runner.err.
Here is an example of a command for starting the Docker container along with configuring the log level for the status.log file:
$ sudo docker run -d --name adcm -p 8000:8000 -v /opt/adcm:/adcm/data -e STATUS_LOG_LEVEL="ERROR" hub.arenadata.io/adcm/adcm:<version>
where <version>
is a desired ADCM image version in one of the following formats:
-
<major>.<minor>.<patch>
— if you need a specific ADCM patch. For example,2.0.0
. -
<major>.<minor>
— if you need the last patch within the selected ADCM version. For example,2.0
.
For more information on special environment variables and possible values, refer to Online installation via a Docker Image.
The LOG_LEVEL
environment variable is available to all log types in order to provide a backward compatibility.
uWSGI logging settings
Configuration of the required settings in the adcm.cfg file located inside the Docker container is the main method of managing the uWSGI logs. The file contains the [uwsgi]
section and is used to set up the uWSGI configuration.
For more information on formats and methods of loading the configuration file supported by uWSGI, refer to the uWSGI documentation.
The adcm.cfg file structure is presented below.
[uwsgi]
touch-reload = /etc/adcm/adcm.cfg
module = adcm.wsgi
master = True
processes = 4
harakiri = 6000
pidfile = /run/uwsgi.pid
socket = /run/adcm.sock
chmod-socket = 777
max-requests = 5000
log-4xx = true
log-5xx = true
disable-logging = true
logto = /adcm/data/log/wsgi.log
log-maxsize = 2000000
Parameter | Description |
---|---|
touch-reload |
Allows you to automatically restart uWSGI when you change the specified file |
module |
Allows you to specify a name of the file which is responsible for running Backend Server on the uWSGI web server |
master |
Allows you to run uWSGI in the |
processes |
Determines a maximum allowable number of processes, i.e. the Backend Server instances |
harakiri |
Determines a maximum amount of time (in seconds) allotted to a process for performing a task. After the allotted time, the process is aborted and started again |
pidfile |
Allows you to specify the path to a file to store the process ID (PID). This parameter is useful in process management |
socket |
Allows you to specify the path of the socket file for interaction between uWSGI and Nginx |
chmod-socket |
Allows you to specify access permissions for the socket file. In adcm.cfg, the socket file is available to be read, written, and executed for all categories of users |
max-requests |
Allows you to restart processes after handling the specified number of requests. You can prevent memory leaks by setting this parameter |
log-4xx |
Allows you to log responses with HTTP status codes of 4xx |
log-5xx |
Allows you to log responses with HTTP status codes of 5xx |
disable-logging |
Allows you to disable uWSGI’s standard logging |
logto |
Allows you to specify the log file path |
log-maxsize |
Determines a maximum log size for log rotation |
To specify the uWSGI custom logging settings:
-
Create a new directory for the adcm.cfg file.
For example:
$ sudo mkdir /opt/myconf
-
Create a new configuration file with the necessary logging settings via the
vi
orvim
command:$ sudo vi adcm.cfg
-
Specify the read, write, and execute permissions for the owner of the file:
$ sudo chmod u=rwx /opt/myconf/adcm.cfg
-
Start the new
adcm
container with the path of the created file:$ sudo docker run -d --name adcm -p 8000:8000 -v /opt/adcm:/adcm/data -v /<file_path>/adcm.cfg/:/etc/adcm/adcm.cfg hub.arenadata.io/adcm/adcm:<version>
where
file_path
is an absolute path to the adcm.cfg configuration file.
Log rotation
By default, ADCM has no automatic log rotation. Therefore, logrotate is used to solve this problem. This utility archives log files when the specified maximum log size is exceeded.
For more information, please refer to the article Use logrotate to configure log rotation.
The logrotate utility applies to all abovementioned log files except the wsgi.log since the log file is automatically rotated as soon as the maximum log size specified in adcm.cfg is reached.
NOTE
You can use log-backupname in the adcm.cfg file to specify the required log file name after its rotation, for example, log-backupname = /opt/adcm/log/uwsgi.log.1 .
|