= log
:type: processor
:status: stable
:categories: ["Utility"]



////
     THIS FILE IS AUTOGENERATED!

     To make changes, edit the corresponding source file under:

     https://github.com/redpanda-data/connect/tree/main/internal/impl/<provider>.

     And:

     https://github.com/redpanda-data/connect/tree/main/cmd/tools/docs_gen/templates/plugin.adoc.tmpl
////

// © 2024 Redpanda Data Inc.


component_type_dropdown::[]


Prints a log event for each message. Messages always remain unchanged. The log message can be set using function interpolations described in  xref:configuration:interpolation.adoc#bloblang-queries[Bloblang queries] which allows you to log the contents and metadata of messages.

```yml
# Config fields, showing default values
label: ""
log:
  level: INFO
  fields_mapping: |- # No default (optional)
    root.reason = "cus I wana"
    root.id = this.id
    root.age = this.user.age.number()
    root.kafka_topic = meta("kafka_topic")
  message: ""
```

The `level` field determines the log level of the printed events and can be any of the following values: TRACE, DEBUG, INFO, WARN, ERROR.

== Structured fields

It's also possible add custom fields to logs when the format is set to a structured form such as `json` or `logfmt` with the config field <<fields_mapping, `fields_mapping`>>:

```yaml
pipeline:
  processors:
    - log:
        level: DEBUG
        message: hello world
        fields_mapping: |
          root.reason = "cus I wana"
          root.id = this.id
          root.age = this.user.age
          root.kafka_topic = meta("kafka_topic")
```


== Fields

=== `level`

The log level to use.


*Type*: `string`

*Default*: `"INFO"`

Options:
`ERROR`
, `WARN`
, `INFO`
, `DEBUG`
, `TRACE`
, `ALL`
.

=== `fields_mapping`

An optional xref:guides:bloblang/about.adoc[Bloblang mapping] that can be used to specify extra fields to add to the log. If log fields are also added with the `fields` field then those values will override matching keys from this mapping.


*Type*: `string`


```yml
# Examples

fields_mapping: |-
  root.reason = "cus I wana"
  root.id = this.id
  root.age = this.user.age.number()
  root.kafka_topic = meta("kafka_topic")
```

=== `message`

The message to print.
This field supports xref:configuration:interpolation.adoc#bloblang-queries[interpolation functions].


*Type*: `string`

*Default*: `""`


