Heya! I'm looking at the <Logging> docs and it is...
# getting-started
j
Heya! I'm looking at the Logging docs and it is not really clear to me how I can go about excluding certain fields from the log 😞 Let's say I have following log message
Copy code
time=2023-03-27 17:45:48 name=target_redshift level=INFO message=Getting catalog objects from table cache... cmd_type=elb consumer=True name=target-dwh producer=False stdio=stderr string_id=target-dwh
I'd like to remove the fields
Copy code
name=target_redshift level=INFO message=Getting catalog objects from table cache...
fields removed • time • cmd_type • consumer • name • producer • stdio • string_id But I can not figure out how to go about doing this, with the
logging.yaml
. Is this at all possible? 🤷
d
Hey! You might want to look at
meltano.core.logging.key_value
formatter with configured
key_order
parameter (https://github.com/meltano/meltano/blob/e14e444a4331812e501b95cbfd2d6c62f46047dc/src/meltano/core/logging/formatters.py#L122) or at just more generic
default
one which you can use to change the format as you want, e.g., like the following:
Copy code
[%(asctime)s] [%(process)d|%(threadName)10s|%(name)s] [%(levelname)s] %(message)s
e
logging.yaml
follows the standard Python logging configuration schema. This means you can use any format you prefer. The logging docs are lacking an example like this, but you can use the a simple format
Copy code
version: 1
disable_existing_loggers: yes
formatters:
  simple:
    format: "[%(levelname)s] %(message)s"
handlers:
  console:
    class: logging.StreamHandler
    level: DEBUG
    formatter: simple
    stream: "<ext://sys.stderr>"
loggers:
  root:
    level: DEBUG
    propagate: yes
    handlers: [console]