×
Community Blog Introduction to Log4j 2 Log System

Introduction to Log4j 2 Log System

In this article, we will introduce Log4j 2 Log System and its advantages in log services.

Log4j 2 is a completely new log system built on Apache Log4j by referencing the logback architecture. Log4j 2 provides support for the Log4j 1.2, SLF4J, Commons Logging and java.util.logging (JUL) APIs. It also supports Java 8 Lambda.

The design ideas of Log4j 2 are inspiring - developing components into plug-ins improves the flexibility. With the rapid development of Internet technologies, various middleware products have been springing up. We need to think more about the relationship between one code and another. Undoubtedly, the decoupled relationship is the most beautiful one.

The LogManager is a critical component. We can see the LogManager which initializes the corresponding LoggerContext is based on the specified LogContextFactory.

LoggerContext is as the following:

1.  Parses the configuration file to obtain the corresponding Java object
2.  Cache log configuration through LoggerRegisty
3.  Obtain the configuration information
4.  Use the start() method to parse the configuration file, and convert the configuration file into the corresponding Java object
5.  Obtain the logger object through getLogger

For details about Log4j 2 on startup, configuration, asynchronization, and plug-in-based components, you can go to Exploring the Secrets of Java Logs: Log4j 2 Log System.

Related Blog Posts

Using Log Service with Alibaba Cloud's Function Compute

Alibaba Cloud's Function Compute service has a range of applications on offer, including API gateways, data lake analysis, log stores and backups, web crawlers and image recognition, to name just a few. With Function Compute, developing is convenient and reliable. Function Compute supports many different programming languages including Java, Python, PHP, and NodeJS.

In this tutorial, we will show you how to create an Alibaba Cloud Log Service project which triggers an Alibaba Cloud Function Compute function.

Alibaba Cloud LOG Java Producer - A Powerful Tool to Migrate Logs to the Cloud

Logs are ubiquitous. As a carrier that records changes in the world, logs are widely used in many fields, such as marketing, research and development, operation, security, BI, and auditing.

This article introduces Alibaba Cloud's LOG Java Producer, an easy-to-use, highly configurable Java library that helps you send data to Log Service.

Related Documentation

Use a consumer group to consume logs

The consumer library is an advanced mode of log consumption in Log Service, and provides the consumer group concept to abstract and manage the consumption end. Compared with using SDKs directly to read data, you can only focus on the business logic by using the consumer library, without caring about the implementation details of Log Service, or the load balancing or failover between consumers.

Access - Log4j/Logback/Producer Lib

In recent years, the advent of stateless programming, containers, and serverless programming greatly increased the efficiency of software delivery and deployment.

0 0 0
Share on

Alibaba Clouder

2,599 posts | 763 followers

You may also like

Comments