////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
////
:documentationPath: /pipeline/transforms/
:language: en_US
:description: The Write To Log transform writes information to the Hop logging system.
:openvar: ${
:closevar: }

= image:transforms/icons/writetolog.svg[Write to log transform Icon, role="image-doc-icon"] Write to log

[%noheader,cols="3a,1a", role="table-no-borders" ]
|===
|
== Description

The Write To Log transform writes information to the Hop logging system.

Typical use cases are logging specific values or custom logging messages to the Hop logs.

|
== Supported Engines
[%noheader,cols="2,1a",frame=none, role="table-supported-engines"]
!===
!Hop Engine! image:check_mark.svg[Supported, 24]
!Spark! image:question_mark.svg[Maybe Supported, 24]
!Flink! image:question_mark.svg[Maybe Supported, 24]
!Dataflow! image:question_mark.svg[Maybe Supported, 24]
!===
|===

== Usage

TIP: Be careful when writing variables or fields for (unencrypted) passwords or other sensitive information to the Hop logging system!

If no fields are added in the Write to log Fields list, it will write out all fields to the log if a Basic Log level is specified. If fields are added to Fields list it will only print out those field(s). Parameters and variables must be specified in the Log message section.  

A Logging level must be set. Set the Log detail level to Basic if you want variables to be printed out.

Example to print a parameter or variable in the Log Message section: ``COUNTER: {openvar}myCounter{closevar}``

If a data row does not exist containing fields, logging fields, parameters, or variables will not work. You may use a "Generate rows" transform to create a dummy row in order to print variables or parameters.

TIP: If an error stops anything from being written to the log, you can disable the Hops that fail, add logging just before the failure, and then re-run.

== Options

[options="header"]
|===
|Option|Description
|Transform Name|Name of the transform this name has to be unique in a single pipeline.
|Log level|The logging level to use.
|Print header|Whether or not the column names for data values is printed.
In the example below, this value has been set to false, so only the actual values (3, 4) are printed.
|Limit rows|Limit the number of rows given by the parameter "Nr. of rows to print".
|Nr. of rows to print|The number of rows to print when option "limit rows" is checked.
|Write to log|The text to use in the logging line(s).
|Fields|The data from fields that should be written to the log.
|===

== Example log output

[source,bash]
----
2020/05/14 12:30:52 - Write to log.0 -
2020/05/14 12:30:52 - Write to log.0 - ----------> Linenr 1----------------------------
2020/05/14 12:30:52 - Write to log.0 - test log
2020/05/14 12:30:52 - Write to log.0 -
2020/05/14 12:30:52 - Write to log.0 -  3
2020/05/14 12:30:52 - Write to log.0 -  4
2020/05/14 12:30:52 - Write to log.0 -
2020/05/14 12:30:52 - Write to log.0 - ====================
2020/05/14 12:30:52 - Write to log.0 -
2020/05/14 12:30:52 - Write to log.0 - ----------> Linenr 2----------------------------
2020/05/14 12:30:52 - Write to log.0 - test log
2020/05/14 12:30:52 - Write to log.0 -
2020/05/14 12:30:52 - Write to log.0 -  3
2020/05/14 12:30:52 - Write to log.0 -  4
2020/05/14 12:30:52 - Write to log.0 -
2020/05/14 12:30:52 - Write to log.0 - ====================
----
