No handlers found for registrar "xhtml2pdf"

I am using xhtmltopdf.pisa to create pdf from an html template. The code worked fine.

pdf = pisa.pisaDocument(StringIO.StringIO(html.encode("UTF-8")), dest=result, link_callback=fetch_resources, default_css=open(pdf_css_path, 'r').read())

But several times I noticed that the code above does not work. The error was equal No handlers could be found for logger "xhtml2pdf". Only a few times can I find this error, but in other cases it just works fine.

Any help is appreciated.

+4
source share
1 answer

, pisa Python . xhtml2pdf. xhtml2pdf .

Django :

LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'formatters': {
    'standard': {
        'format': "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
        'datefmt': "%d/%b/%Y %H:%M:%S"
        },
    },
    'handlers': {
        'logfile': {
            'level': 'DEBUG',
            'filename': BASE_DIR + "/Log/info.log"
        },
        'console': {
            'level': 'INFO',
            'class': 'logging.StreamHandler',
            'formatter': 'standard'
        },
    },
    'loggers': {
        'django': {
            'handlers': ['console'],
            'propagate': True,
            'level': 'WARN',
        },
        'xhtml2pdf': {
            'handlers': ['logfile'],
            'level': 'DEBUG'
       },
   }
}

bacause, pisa .

+3

Source: https://habr.com/ru/post/1610618/


All Articles