如何使用日志记录

    Log4j is controlled using property files. In Flink’s case, the file is usually called . We pass the filename and location of this file using the -Dlog4j.configuration= parameter to the JVM.

    Flink ships with the following default properties files:

    • log4j-cli.properties: Used by the Flink command line client (e.g. flink run) (not code executed on the cluster)
    • : Used by the Flink command line client when starting a YARN session (yarn-session.sh)

    In order to control the logging level of , for example, one would have to add the following line to the configuration file.

    For further information on configuring logback see LOGback’s manual.

    In order to benefit most from slf4j, it is recommended to use its placeholder mechanism.Using placeholders allows to avoid unnecessary string constructions in case that the logging level is set so high that the message would not be logged.The syntax of placeholders is the following:

    Placeholders can also be used in conjunction with exceptions which shall be logged.