1

I'm using pyppeteer to take screenshots of images to a make a pdf but pyppeteer auto logs everything I take a screenshot at and because of server limitations and the logs is written to a file the logs are crashing my server.

Is there any way to completely disable logging? I tried this already:

        'logLevel': logging.NOTSET,

        'env': {'DEBUG': 'puppeteer:*,-not_this'},

I also tried to disable logging like this:

logging.getLogger('pyppeteer').setLevel(logging.NOTSET)

And nothing seems to work.

Update

I managed to found a workaround although not a solution by disabling all logging in the application like this:

logging.disable(logging.CRITICAL)

# pyppeteer code...

logging.disable(logging.NOTSET)
theDavidBarton
  • 7,643
  • 4
  • 24
  • 51
Juan Carlos
  • 578
  • 5
  • 22

2 Answers2

1

Try this:

logging.getLogger("<logger name>").disabled = True

If you want to disable all loggers you can use:

for name in logging.root.manager.loggerDict:
    # print("logger", name)
    logging.getLogger(name).disabled = True

Or maybe if you want to disable all except some loggers you created:

allowed_loggers = ['some_logger']
for name in logging.root.manager.loggerDict:
    # print("logger", name)
    if name in allowed_loggers:
        continue
    logging.getLogger(name).disabled = True

Faizan AlHassan
  • 389
  • 4
  • 8
-1

This should log all of your errors to a file.

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'simple': {
            'format': '{asctime} {name}] {message}',
            'style': '{',
        }
    },
    'handlers': {
        'file': {
            'level': 'ERROR',
            'class': 'logging.FileHandler',
            'filename': 'error.log',
            'formatter': 'simple',
        },
    },
    'loggers': {
        'django': {
            'handlers': ['file'],
            'level': 'ERROR',
            'propagate': True,
        },
        '': {
            'handlers': ['file'],
            'level': 'ERROR',
            'propagate': False,
        },
    },
}

alter123
  • 601
  • 2
  • 11
  • 32