Skip to content

Logging

Logging is implemented using the Python default logging module. Configuration of all logging functions ban be done via a configuration file or environment variables and defined in the logging.config.

Gunicorn Logging

The Gunicorn logging is configured in the gunicorn.config.py file. The logging level is set to debug with the parameter loglevel and the log file will be located at ../logs/gunicorn.log according to the parameter ../logs/gunicorn.log.

Feature List

Key features of the logging module are:

  • Configuration of all logging functions via a configuration file or environment variables. This includes the thid party libraries.

  • UVICORN

  • GUNICORN

  • One log file for each logging section or the option to combine multiple logging outputs into one file.

  • uvicorn.access
  • uvicorn.error
  • gunicorn.http
  • ImageTransformSvc
  • ImageTransformSvc.Timing
  • Individual logging levels for each logging section.
  • The deactivation of the STDOUT logging output. Which can hurt the performance of the application.
  • TimedRotatingFileHandler for the logfiles with the options for:
  • interval: time / intervall between log file rotation
  • backupCount: number of logfiles to keep
  • when: at which time the logfile should be rotated
    • ([d] daily, [h] hourly, [m] minutely, [s] secondly, midnight)
  • The applications support the programmatic creation of filter functions for each logging section.

Logging Levels

The following logging levels are used in the application:

Level When it’s used
DEBUG Detailed information, typically of interest only when diagnosing problems.
INFO Confirmation that things are working as expected.
WARNING An indication that something unexpected happened or indicative of some problem in the near future (e.g. ‘disk space low’). The software is still working as expected.
ERROR Due to a more serious problem, the software cannot perform some functions.
CRITICAL A serious error indicates that the program cannot continue running.

The logging levels are hierarchically ordered. If you set the logging level to WARNING, you will also see the ERROR and CRITICAL messages. You will see all the messages if you set the logging level to DEBUG.

UVICORN ACCESS LOGGING

If set to info, the uvicorn access logger will log every request to the application. This can be very useful for debugging and performance monitoring. The log file will be located at ../logs/ImageTransformSvcUvicornAccess.log and will be rotated daily. The number of log files to keep is set to 7. The log file will be rotated at midnight.

Parameter Type Default Description
LOGGING_UVICORN_ACCESS_STDOUT bool True Activates STDOUT; Deactivate for better performance.
LOGGING_UVICORN_ACCESS_LEVEL str INFO Log level; Logs this level and all above
LOGGING_UVICORN_ACCESS_LOCATION str ../logs/ImageTransformSvcUvicornAccess.log Log file location. Can be the same for multiple loggers
LOGGING_UVICORN_ACCESS_WHEN str midnight At which time the logfile should be rotated. [d] daily, [h] hourly, [m] minutely, [s] secondly, midnight
LOGGING_UVICORN_ACCESS_BACKUP_COUNT int 7 Number of logfiles to keep
LOGGING_UVICORN_ACCESS_INTERVAL int 1 Time / Intervall between log file rotation

UVICORN ERROR LOGGING

If set to info, the uvicorn error logger will log every error or generall startup information of the application. The log file will be located at ../logs/ImageTransformSvcUvicornError.log and will be rotated daily. The number of log files to keep is set to 7. The log file will be rotated at midnight.

Parameter Type Default Describtion
LOGGING_UVICORN_ERROR_STDOUT bool True Activates STDOUT; Deactivate for better performance.
LOGGING_UVICORN_ERROR_LEVEL str INFO Log level; Logs this level and all above
LOGGING_UVICORN_ERROR_LOCATION str ../logs/ImageTransformSvcUvicornError.log Log file location. Can be the same for multiple loggers
LOGGING_UVICORN_ERROR_WHEN str midnight At which time the logfile should be rotated. [d] daily, [h] hourly, [m] minutely, [s] secondly, midnight
LOGGING_UVICORN_ERROR_BACKUP_COUNT int 7 Number of logfiles to keep
LOGGING_UVICORN_ERROR_INTERVAL int 1 Time / Intervall between log file rotation

ImageTransformSvc LOGGING

Loggs with respect to the log level everthing related the to the ImageTransformSvc.

Parameter Type Default Describtion
LOGGING_STDOUT bool True Activates STDOUT; Deactivate for better performance.
LOGGING_LEVEL str INFO Log level; Logs this level and all above
LOGGING_LOCATION str ../logs/ImageTransformSvcUvicornError.log Log file location. Can be the same for multiple loggers
LOGGING_WHEN str midnight At which time the logfile should be rotated. [d] daily, [h] hourly, [m] minutely, [s] secondly, midnight
LOGGING_BACKUP_COUNT int 7 Number of logfiles to keep
LOGGING_INTERVAL int 1 Time / Intervall between log file rotation

ImageTransformSvc TIMING LOGGING

Loggs the timing measurements of the ImageTransformSvc.

Parameter Type Default Describtion
LOGGING_TIMING_STDOUT bool True Activates STDOUT; Deactivate for better performance.
LOGGING_TIMING_LEVEL str INFO Log level; Logs this level and all above
LOGGING_TIMING_LOCATION str ../logs/ImageTransformSvcUvicornError.log Log file location. Can be the same for multiple loggers
LOGGING_TIMING_WHEN str midnight At which time the logfile should be rotated. [d] daily, [h] hourly, [m] minutely, [s] secondly, midnight
LOGGING_TIMING_BACKUP_COUNT int 7 Number of logfiles to keep
LOGGING_TIMING_INTERVAL int 1 Time / Intervall between log file rotation