Skip to main content

Python

To collect logs by your Python application, check the following.

Agent Update

It is available from Python agent 1.2.2. For more information about update, see the following.

Checking the agent settings

Home > Select Project > Log > Log Setting

Select a project in the initial screen of the WhaTap monitoring service, and then select Log > Log Setting under Project Menu. Proceed with the process according to the instructions in the Check Agent Settings tab of the Start Log Monitoring section.

Enabling the collection of logs

If you enter the command including the configuration file path (WHATAP_HOME), log collection starts.

export LOGFILES={Log file's full path},...
echo "logsink_enabled=true" | sudo tee -a {Configuration file path}/whatap.conf
echo "logsink.files=$LOGFILES" | sudo tee -a {Configuration file path}/whatap.conf

Linking the log and web transaction

Version 1.3.6 or later

Starting from the version 1.3.6, transactions and logs can be integrated using the following methods. Currently, WhaTap supports the Python's logging and loguru libraries. Configure whatap.conf according to your Python log libraries.

  • logging module

    logging

    echo "trace_logging_enabled=true" | sudo tee -a {configuration file path}/whatap.conf

  • loguru module

    loguru

    echo "trace_loguru_enabled=true" | sudo tee -a {configuration file path}/whatap.conf

Version 1.3.6 or earlier

The transaction ID {txid} is output to the log so that the logs generated by each transaction can be viewed separately. WhaTap Monitoring automatically injects {txid} into Python LogRecord so that {txid} can be output to the log file when setting the formatter.

settings.py
...
LOGGING = {
...
'formatters': {
...
},
'handlers': {
...
},
'loggers': {
...
'{로거이름}': {
'handlers': [...],
...
},
},
}

try:
import whatap.trace.mod.logging as whatap_logging
if whatap_logging.logging_injection_processed:
LOGGING['formatters']['whatap.formatter']={
'()': 'django.utils.log.ServerFormatter',
'format': '[{server_time}] -- {{ "@txid" : "{txid}" }} -- {message}',
'style': '{',
}
LOGGING['handlers']['whatap']={
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(BASE_DIR, 'logs','whatap_log.log'),
'formatter': 'whatap.formatter',
}
LOGGING['loggers'][{Logger name}]['handlers'].append('whatap')
except:
pass
...

Enabling the log monitoring

Home > Select Project > Log > Log Setting

You can enable or disable the WhaTap log monitoring with the toggle button in the Activate log monitoring tab of the Starting the log monitoring section.

Starting the log monitoring

  • If you turn on Icon, the log monitoring is enabled. You can try for free for 15 days from the activation date.
  • If you turn off Icon, the log monitoring is disabled. Logs are no longer saved.
Note

Role

After agent installation, you can enable the log monitoring settings only when you have the edit permission on the project. For more information about the roles, see the following.