I have a basic setup from a logging.ini file so that my console prints human readable logs, but I print JSON dict-like logs to file, so my ELK can process the logs.
[formatter_json]
class=pythonjsonlogger.jsonlogger.JsonFormatter
format=%(asctime)s %(name)s %(levelname)s %(message)s
[formatter_simpleFormatter]
format=%(asctime)s %(name)s - %(levelname)s:%(message)s
When logging messages, I often add extra fields, ad-hoc, like so:
logger.info("hello world, I like the word %s", "cowabanga", extra={"more":15})
And so the field more:15 appears in the log line in my file. But it does not appear in the console, which would just say 2019-06-12 13:25:02,189 root - INFO:hello world, I like the word cowabanga
. What do I need to do to have 15 or more:15 appear (I don't care exactly in what order the extra parameters would appear, just that they appear)?