我有一个python日志记录配置,如下所示:
LOGGING_CONFIG:
version: 1
formatters:
human:
class: logging.Formatter
format: '[%(asctime)s]:[%(levelname)s]: %(message)s'
json:
class: pythonjsonlogger.jsonlogger.JsonFormatter
format: '%(asctime)s %(levelname)s %(message)s'
handlers:
console:
class: logging.StreamHandler
level: DEBUG
formatter: json # change this to 'human' when you run it locally, json in production
file:
class: logging.FileHandler
filename: logfile.log
level: DEBUG
formatter: json
root: # Logging for 3rd party stuff
level: INFO
handlers:
- console
- file
project_name: # Logging this module
level: DEBUG
handlers:
- console
- file
对于另一个系统,我需要结构化日志记录有一些固定的名称。一个例子是它不应该
levelname
但是
level
. 如何重命名日志字段?
我所拥有的:
{"asctime": "2018-10-22 14:50:19,923", "levelname": "info", "message": "foobar"}
我想要的是:
{"asctime": "2018-10-22 14:50:19,923", "level": "info", "message": "foobar"}