Spring / Spring Boot 4 Basics Interview Questions
How does Spring Boot 4 handle logging configuration?
Spring Boot 4 auto-configures Logback as the default logging framework (with SLF4J as the facade). Log4j2 and JUL are also supported. Boot 4 enhances structured logging for production observability.
# Logging configuration in application.yml: logging: level: root: INFO # global default level com.example.service: DEBUG # package-specific level org.springframework.security: WARN # reduce security noise org.hibernate.SQL: DEBUG # log SQL statements org.hibernate.orm.jdbc.bind: TRACE # log SQL parameters file: name: /var/log/order-service/app.log logback: rollingpolicy: max-file-size: 100MB max-history: 30 pattern: console: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n" file: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} [%X{traceId},%X{spanId}] - %msg%n" // Structured logging (JSON) for production / log aggregation: logging: structured: format: console: ecs # Elastic Common Schema file: logstash # Logstash JSON format # Output: machine-readable JSON logs for ELK stack // Using SLF4J in application code: @Service public class OrderService { private static final Logger log = LoggerFactory.getLogger(OrderService.class); // Or with Lombok: // @Slf4j // public class OrderService { public Order createOrder(CreateOrderRequest req) { log.debug("Creating order for product: {}", req.productId()); Order order = repo.save(new Order(req)); log.info("Order created successfully: id={}, product={}", order.id(), order.productId()); return order; } } // Change log level at runtime via Actuator: // POST /actuator/loggers/com.example.service // Body: {"configuredLevel": "DEBUG"}
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
