Customizing the log file
You can customize the logging process to track the Wazi Deploy execution messages and errors, and write them to the log file.
To do so, you must specify a --logConfigFile argument in The Wazi Deploy packager command and The Wazi Deploy generation command. If you do not, then the default logging process applies when you run
Wazi Deploy.
By default, the messages are written to the message.log file. The logging process is managed in a logging.yml file.
version: 1
formatters:
default:
format: '%(asctime)s - %(levelname)-5s - %(message)s'
datefmt: '%Y-%m-%d %H:%M:%S'
handlers:
console:
class: logging.StreamHandler
level: INFO
formatter: default
stream: ext://sys.stdout
file:
class : logging.handlers.RotatingFileHandler
formatter: default
filename: message.log
maxBytes: 1024000
backupCount: 3
root:
level: NOTSET
handlers: [console]
propagate: yes
loggers:
log-deploy:
level: INFO
handlers: [file]
propagate: noTo understand this file, you must read it from the end. Only the Wazi Deploy specific information is explained. The other information is standard logging information.
loggers block contains the following information:log-deployis the required logger name. If you enter another name, the log information is displayed in the console only, and not in the log file.levelis the level of the log that is written to the log file. The levels that can be output by Wazi Deploy areINFO(default) andDEBUG. TheDEBUGlevel is more verbose than theINFOlevel, as it gives troubleshooting information.Note: The level does not apply to the messages that are displayed in the console.handlers: [file]refers to thefilehandler that is defined in thehandlersblock.
The handlers block contains the file handler, which is defined
with a logging.handlers.RotatingFileHandler class. It means that when the size of
the log file (filename: message.log) exceeds the maxBytes
number, it creates a second log file (message2.log). When the size of the
second log also exceeds the maxBytes number, it creates a third log file
(message3.log). Such is the purpose of backupCount: 3. When
the third log file exceeds the maxBytes number, it reuses the first log file. This
rotating file handler prevents the creation of too many files in your execution directory.
formatters block contains the format of the messages that are written to the
log file. By default, the messages are constituted of the following elements, separated by a dash (-):%(asctime)sfor the data and time of the message creation.%(levelname)-5sfor the message level. The possible levels are specified in theloggersblock.%(message)sfor the message that explains the origin of the error. This message is constituted of the following parts:- The element, line and file where the error was detected.
- The message itself.
2023-05-15 15:44:07 - INFO - deployment_method_manager.py, line 31, in load_deployment_method_from_yaml_file : \* Read the deployment method from: xxxxxxThe logging process is a Python process. You can refer to the Python documentation for general and exhaustive information about the logging process.