Skip to content

Instantly share code, notes, and snippets.

@royz
Last active August 23, 2020 12:35
Show Gist options
  • Save royz/d62932ab1654993c54639dc9ff5a8844 to your computer and use it in GitHub Desktop.
Save royz/d62932ab1654993c54639dc9ff5a8844 to your computer and use it in GitHub Desktop.
import sys
import logging
from logging.handlers import RotatingFileHandler
logging.basicConfig(
level=logging.DEBUG,
format='[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s',
handlers=(
RotatingFileHandler(
filename='logs.log',
maxBytes=(1024 ** 3) / 2, # max log file size 512MB
backupCount=1,
),
logging.StreamHandler(sys.stdout)
)
)
logger = logging.getLogger()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment