Created
November 11, 2019 19:39
-
-
Save cmandesign/0e00e14aae17f779243cc07abc359ec4 to your computer and use it in GitHub Desktop.
Flask Basic Logger Config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from logging.config import dictConfig | |
# Import Log Base Path From Config File | |
# The output should be something like this | |
# log_base_path = "/var/log/" | |
log_base_path = your_config.LOG_BASE_PATH | |
logging_dict = { | |
'version': 1, | |
'disable_existing_loggers': False, | |
'formatters': { | |
'JSONPERLINE': { | |
'format': '%(message)s' | |
}, | |
}, | |
'handlers': { | |
'inbound_requests': { | |
'level': 'DEBUG', | |
'class': 'logging.FileHandler', | |
'filename': os.path.join(log_base_path, 'inbound_requests.log'), | |
'formatter': 'JSONPERLINE' | |
} | |
}, | |
'loggers': { | |
'inbound_requests': { | |
'handlers': ['inbound_requests'], | |
'level': 'INFO' | |
} | |
} | |
} | |
dictConfig(logging_dict) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment