1. 程式人生 > 實用技巧 >centos7防火牆firewalld拒絕某ip或者某ip段訪問伺服器任何服務

centos7防火牆firewalld拒絕某ip或者某ip段訪問伺服器任何服務

# coonfig 版本
# create config
BASE_DIR = os.path.dirname(__file__)
BASE_LOG_DIR = os.path.join(BASE_DIR, "log")
if not os.path.exists(BASE_LOG_DIR):
    os.mkdir(BASE_LOG_DIR)
log_config = {
    'version': 1,
    'disable_existing_loggers': False,
    'loggers': {
        'django': {
            'handlers
': ['TimedRotatingFileHandler'], 'level': 'DEBUG', "propagate": True } }, 'handlers': { 'console': { 'class': 'logging.StreamHandler', "level": "DEBUG", "formatter": "simple" }, 'filehander': {
'class': 'logging.FileHandler', 'filename': 'log.log', "level": "WARNING", "formatter": "verbose" }, 'RotatingFileHandler': { 'class': 'logging.handlers.RotatingFileHandler', 'level': 'ERROR', 'filename': os.path.join(BASE_LOG_DIR, "
project_error.log"), # 日誌檔案 'maxBytes': 1024 * 1024 * 1024 * 1, # 1GB 'backupCount': 3, # 備份數為3 xx.log --> xx.log.1 --> xx.log.2 --> xx.log.3 'formatter': 'verbose', 'encoding': 'utf-8', }, # 備份程式碼出錯的地方 'TimedRotatingFileHandler': { 'class': 'logging.handlers.TimedRotatingFileHandler', 'level': 'INFO', 'filename': os.path.join(BASE_LOG_DIR, "project_info.log"), # 日誌檔案 'backupCount': 30, # 備份數為 xx.log --> xx.log.1 --> xx.log.2 --> xx.log.3 'when': 'D', 'formatter': 'simple', 'encoding': 'utf-8', }, # 備份日常的資訊 }, 'formatters': { 'verbose': { 'format': '[%(asctime)s][%(threadName)s:%(thread)d][task_id:%(name)s][%(filename)s:%(lineno)d]' '[%(levelname)s][%(message)s]', 'datefmt': '%Y-%m-%d %H:%M:%S' }, 'simple': { 'format': '[%(levelname)s][%(asctime)s][%(filename)s:%(lineno)d]%(message)s', 'datefmt': '%Y-%m-%d %H:%M:%S' } } } logging.config.dictConfig(log_config) # create logger logger = logging.getLogger('django') # 'application' code logger.debug('debug message') logger.info('info message') logger.warning('warn message') logger.error('error message') logger.critical('critical message')