Answer the question
In order to leave comments, you need to log in
Python logging, how to enable support for Russian letters?
I write logs using logging.config in Python. The problem is that I format the logs in JSON and if there are Russian letters, then it logs like this: {\\n \"errors\": [\\n \"\u0414\u043e\u043a\u0443\u043c\u0435 \u043d\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\"\\n ]\\n}'
I can't set it up, please help
[loggers]
keys=root
[handlers]
keys=fileHandler
[formatters]
keys=json
[logger_root]
level=INFO
handlers=fileHandler
[handler_fileHandler]
class=FileHandler
level=INFO
formatter=json
args=('%(logfilename)s',)
[formatter_json]
class=pythonjsonlogger.jsonlogger.JsonFormatter
format=%(asctime)s - %(levelname)s - %(module)s - %(funcName)s - %(message)s
datefmt=%Y-%m-%d %H:%M:%S
logger = logging.getLogger(__name__)
logging.config.fileConfig(
'logging.ini',
defaults={'logfilename': 'test.log'},
disable_existing_loggers=False
)
logger.warning(messange)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question