By Taiye , from Alibaba Cloud Storage Team
Alibaba Cloud Toolkit is an IDE-targeted plug-in for developers that helps them efficiently develop and deploy applications for cloud environments. After completing the development, debugging, and testing of your application locally, you can install Alibaba Cloud Toolkit in the IDE, such as Eclipse or IntelliJ. You can connect to a cloud environment and deploy your application to the cloud through graphical configuration.
Online troubleshooting is an essential experience for a software developer. In services of different maturity levels, the processes of online troubleshooting vary slightly. For software developed by some small start-up companies, its service may still be single-point, or a cluster is built by several machines. Therefore, we need to go to each server and check the logs of each service through SSH. Companies with higher maturity will build their own log service platform or use a mature log platform like SLS to organize and manage online logs. This saves the trouble of checking logs on the server through SSH and significantly improves troubleshooting efficiency.
However, it is still not perfect. Here is a common scenario. When an exception occurs online, we will find the service log on the page of the log service platform, such as the Java Stack Trace. The Java Stack Trace is usually long. So, we need to switch back and forth between the page and IDE of the log service platform to accurately find the exception from the codebase. In some cases, when the log takes too long, we also need to copy the log to the local file. Switching back and forth between different windows wastes a lot of precious time.
Alibaba Cloud Toolkit integrates the functions of the SLS log platform to conveniently and accurately associate the logs of the Log Service platform with the code, helping software developers easily query the desired logs in IDE. Log Service is a cloud-native monitoring and analysis platform. It provides large-scale, low-cost, and real-time services to process multiple types of data, such as Log, Metric, and Trace. Log Service allows you to collect, transform, query, analyze, visualize, ship, and consume data. You can also configure alerts in the console. It also helps enterprises improve their digital capabilities in terms of R&D, O&M, and data security.
Let's look at a common Java service exception troubleshooting scenario and see how convenient SLS is in the Alibaba Cloud Toolkit plug-in.
First, we can simulate a service with an online exception. Create a simple springboot service and implement a Component bean of ApplicationRunner. This is very simple. It prints a line of NPE logs every second to simulate the service of NPE online.
@Component
@Slf4j
public class LogDemoService implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
while (true) {
try {
String field = null;
System.out.println(field.length());
Thread.sleep(1000);
} catch (Exception e) {
log.error("write exception log :", e);
}
}
}
}
After the service is packaged, start the service on the server.
Then, we can deploy the log collection service of SLS on the server. Please see this link for specific operation files.
This step will collect logs to the logstore of SLS:
After we confirm the logs have been successfully collected on the SLS page, the service simulation and the access to the log platform have been completed. Let's return to IDE.
First, we can find the Alibaba Cloud Toolkit through the marketplace of plug-ins of IntelliJ. Click install and then restart IDE for it to take effect:
Click Tools → Alibaba Cloud → Preference to configure the account information. You need to enter the Access Key Id and Access Key Secret of the account that has permission to view SLS logs.
Click Tools → Alibaba Cloud → Alibaba Cloud View → Alibaba Cloud SLS
Now, you can see the log query interface of SLS at the bottom of the IDE window.
After selecting the corresponding region and project, click the view button on the right side of the corresponding logstore.
Just like the SLS page, you can view the logs of the services in IDE. This interface also supports the filtering of log time ranges and the filtering of query and analysis statements, which can help developers quickly and accurately find the desired log data. Please refer to this link for SLS query and analysis statements.
It is impossible to see the complete information at one time in this interface with long logs like the Java Stack Trace. There is an "Open in Editor" button on the right side of each log in the query results.
Click it, and you can view this log on the new page of IDE, which is convenient for developers to obtain the complete information.
Alibaba Cloud Toolkit is an excellent plug-in. It adds the function of the Log Service and integrates the functions of the Log Service platform into IDE for common problem troubleshooting scenarios in software developers' daily work. This saves the time of switching back and forth between windows and improves the daily work efficiency.
Use Command Line on the Terminal to Implement Visualized Analysis of Logs
How Is Alibaba Cloud Empowering the Startup Ecosystem in Malaysia?
1,048 posts | 257 followers
FollowAlibaba Cloud Community - July 5, 2022
Alibaba Developer - August 18, 2020
Alibaba Cloud Native - June 27, 2024
Aliware - May 20, 2019
Alibaba Developer - April 7, 2020
H Ohara - March 13, 2024
1,048 posts | 257 followers
FollowAn all-in-one service for log-type data
Learn MorePlan and optimize your storage budget with flexible storage services
Learn MoreA secure environment for offline data development, with powerful Open APIs, to create an ecosystem for redevelopment.
Learn MoreLog into an artificial intelligence for IT operations (AIOps) environment with an intelligent, all-in-one, and out-of-the-box log management solution
Learn MoreMore Posts by Alibaba Cloud Community