Operations 10 min read

Master Real-Time Logging and Debugging for Serverless Spring Boot Apps

This article explains how to monitor, collect, and analyze real‑time logs, use multi‑dimensional metrics, perform local debugging, and enable cloud‑edge debugging for Spring Boot applications running on a Serverless platform, providing step‑by‑step commands and visual guides.

Alibaba Cloud Developer
Alibaba Cloud Developer
Alibaba Cloud Developer
Master Real-Time Logging and Debugging for Serverless Spring Boot Apps

Spring Boot, built on the Java Spring framework, bundles many components so developers can create standalone applications with minimal configuration. In cloud‑native environments, Serverless is an attractive way to run Spring Boot apps.

The series analyzes Serverless platforms for Spring Boot from five aspects—architecture, deployment, monitoring, performance, and security—using the popular open‑source e‑commerce project mall (over 50k GitHub stars) as an example.

Real‑time Logs

Logging is the primary debugging tool for distributed cloud applications. While many open‑source solutions exist, they require significant setup and maintenance. Alibaba Cloud Function Compute provides built‑in log collection and analysis: simply output logs in your code and they are automatically gathered, aggregated, and viewable in real time.

Using the Serverless Devs CLI, you can create a log repository and view logs with commands such as: sudo -E s logs To view logs for a specific service: sudo -E s mall-admin logs Adding the -t flag enables tailing mode for live log streaming: sudo -E s mall-admin logs -t You can also filter by keyword, for example to see only ERROR level logs: s mall-admin logs -t --keyword=ERROR The Function Compute console also offers multi‑dimensional log queries by function, instance, request, etc., and displays request lists with execution details, memory usage, duration, and associated logs.

Metrics Multi‑dimensional Query

Beyond logs, the console shows monitoring metrics for each function instance, including success/failure counts, execution time, memory consumption, and instance details. Users can also view instance lists and even log into instances for deeper inspection.

Local Debugging

Before deploying to the cloud, you can run the application locally with Serverless Devs. In the project root (where s.yaml resides), execute: sudo -E s mall-admin local start auto The tool starts a local function instance and provides a temporary URL, allowing you to debug the web application locally. Each launch uses a randomly assigned port.

Cloud‑Edge (端云) Debugging

Complex micro‑service architectures often require end‑to‑end testing across cloud services. Serverless Devs’ cloud‑edge debugging creates a secure tunnel between your local machine and the cloud VPC, allowing local instances to access cloud resources (e.g., RDS) without exposing them publicly.

For the mall-admin service, you can set up cloud‑edge debugging with: sudo -E s mall-admin proxied setup After setup, requests to mall-admin-web are forwarded to the local mall-admin instance, while the local instance can seamlessly reach cloud databases and other services. To revert traffic back to the cloud, redeploy with s deploy.

Summary

Debugging and observability remain the top pain points for Serverless developers. Alibaba Cloud Function Compute, together with Serverless Devs, offers built‑in real‑time monitoring, instance metrics, and login capabilities, as well as local, cloud‑edge, and remote debugging, significantly improving developer efficiency and satisfaction.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DebuggingCloud NativeServerlessOperationsloggingSpring Boot
Alibaba Cloud Developer
Written by

Alibaba Cloud Developer

Alibaba's official tech channel, featuring all of its technology innovations.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.