This topic describes how to analyze Log4j logs in the Log Service console. The logs of an e-commerce company are used as an example.
Prerequisites
- Log4j logs are collected. For more information, see Collect Log4j logs.
- The indexing feature is enabled for the Logstore and indexes are configured. For more
information, see Enable and configure the index feature for a Logstore.
The following figure shows the indexes that are used in this example.
Background information
Log4j is an open source project of Apache. Log4j allows you to specify the output destination and format of logs. You can also specify the severity level of logs. The severity levels of logs are classified into ERROR, WARN, INFO, and DEBUG in descending order. The output destination specifies whether logs are sent to the console or files. The output format specifies the format of logs.
In this example, an e-commerce company wants to obtain the best solution for the platform.
The company needs to analyze information that includes behavioral data, such as logon
methods, logon time, logon duration, accessed pages, access duration, average order
time, and consumption level, platform stability, system errors, and data security.
Log Service provides multiple log collection methods and the log analysis feature.
Sample logs are collected by Log Service, as shown in the following examples.
- The following log indicates the logon information:
level: INFO location: com.aliyun.log4jappendertest.Log4jAppenderBizDemo.login(Log4jAppenderBizDemo.java:38) message: User login successfully. requestID=id4 userID=user8 thread: main time: 2018-01-26T15:31+0000
- The following log indicates the purchase information:
level: INFO location: com.aliyun.log4jappendertest.Log4jAppenderBizDemo.order(Log4jAppenderBizDemo.java:46) message: Place an order successfully. requestID=id44 userID=user8 itemID=item3 amount=9 thread: main time: 2018-01-26T15:31+0000