Changes
Jump to navigation
Jump to search
← Older edit
Newer edit →
Python logging dict config
(edit)
Revision as of 14:30, 27 November 2021
92 bytes added
,
14:30, 27 November 2021
m
no edit summary
Line 1:
Line 1:
−
<source lang=python>
+
<source lang=
"
python
"
>
+
import os
import logging.config
import logging.config
+
def set_logging(log_level='DEBUG', # Logging levels available: 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'
def set_logging(log_level='DEBUG', # Logging levels available: 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'
−
logs_path="
/var/fotingo/
",
+
logs_path="
logger.log
",
keep_logs=7,
keep_logs=7,
log_max_size=52428800 # 50 * 1024 * 1024 bytes
log_max_size=52428800 # 50 * 1024 * 1024 bytes
Line 55:
Line 57:
}
}
return logging
return logging
+
</source><syntaxhighlight lang="python">
+
from logger import set_logging
+
BASE_DIR = '.'
BASE_DIR = '.'
LOGGING = set_logging(logs_path=os.path.join(BASE_DIR, 'logs'))
LOGGING = set_logging(logs_path=os.path.join(BASE_DIR, 'logs'))
logging.config.dictConfig(LOGGING)
logging.config.dictConfig(LOGGING)
−
logger = logging.getLogger('
fotingo
')
+
logger = logging.getLogger('
logger
')
−
logger.debug('Test logger')</
source
>
+
logger.debug('Test logger')
+
</
syntaxhighlight
>
Rafahsolis
Bureaucrats
,
Administrators
2,306
edits
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
Variants
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
Special pages
Printable version