I am trying to log from python using a json config file which controls the configuration of the logger , below is sample config I am using
{
"version": 1,
"disable_existing_loggers": true,
"formatters": {
"json": {
"format": "%(asctime)s %(levelname)s %(filename)s %(lineno)s %(message)s"
}
},
"handlers": {
"json": {
"class": "logging.StreamHandler",
"formatter": "json"
}
},
"loggers": {
"": {
"handlers": ["json"],
"level": 20
}
}
}
This works fine but is there any Doc which would point to different formatters that are available to be used or similarly different handlers that can be used ?
Handlers
The different handlers you can choose from are listed in the docs. Among the different handlers, there are:
StreamHandler
that "sends logging output to streams such as sys.stdout, sys.stderr or any file-like object"FileHandler
that "sends logging output to a disk file"SocketHandler
that "sends logging output to a network socket"SysLogHandler
that "supports sending logging messages to a remote or local Unix syslog".Formatters
logging.Formatter
s can use any of the followingLogRecord
attributes inside thefmt
string.For example,