Log4j is an open source logging framework developed by Apache. You can use Log4j to print logs to a console, file, Graphical User Interface (GUI) component, socket server, NT kernel logger, or Unix syslog daemon. You can define the output format of each log entry. You can also define the level of each log entry to achieve fine-grained control over the generation of logs.

Log4j consists of three main components: loggers, appenders, and layouts.
  • Loggers define log entry levels to indicate the severity of log entries.

    Log entry levels are classified into ERROR, WARN, INFO, and DEBUG in descending order of severity.

  • Appenders deliver log entries to different destinations.

    A destination can be a console or file.

  • Layouts define the output format of logs.

    They specify how logs are displayed.

You can use Alibaba Cloud Log Log4j Appender to print logs to Log Service. For information about the download link and user guide, see Log4j Appender.