How to Trace Microservices Logs with Spring Cloud Sleuth and Zipkin

Introduction Here I am going to explain how to trace Spring Boot Microservices logs with Spring Cloud Sleuth and Zipkin Server. Spring Cloud Sleuth provides Spring Boot auto-configuration for distributed tracing. One of the problems most developers face difficulty of tracing logs as your microservices applications grow and requests propagate from one microservice to another microservice. So it could be quite part to try to figure out how a particular request travels through the application when you don’t have any idea regarding the implementation of microservices you are calling.

Continue

How to log with Lombok using @slf4j annotation in Java, Spring and Spring Boot Applications

Introduction In this tutorial I will show you how to configure Lombok for logging using @slf4j annotation in Java, Spring and Spring Boot applications. The example shown here will work for Java, Spring and Spring Boot applications. This annotation will reduce the code you write for creating logger variable. Lombok will provide log variable when you use @slf4j annotation on class level. You can use this log variable to create log statements. I am going to use log4j2 with slf4j API for Java, Spring and Spring Boot applications. You can…

Continue

How to create separate log file for each module using SiftingAppender and MDC (Mapped Diagnostic Context) in logback

Introduction In this example we will see how to create or generate separate log file module-wise or for each separate functionality using SiftingAppender in logback with the help of ThreadedContext or MDC in Spring Boot applications. MDC or Mapped Diagnostic Context is a lighter technique consists of uniquely stamping each log request servicing a given client. To uniquely stamp each request, the user puts contextual information into the MDC. In our previous example we have seen how to configure logback for Spring Boot Applications but here we will control multiple log files…

Continue

How to create separate log file for each module using RoutingAppender and MDC (Mapped Diagnostic Context) in log4j2/slf4j

Introduction In this example we will see how to create or generate separate log file module-wise or for each separate functionality using RoutingAppender in log4j2 with the help of ThreadedContext or MDC. MDC or Mapped Diagnostic Context is a lighter technique consists of uniquely stamping each log request servicing a given client. To uniquely stamp each request, the user puts contextual information into the MDC. In our previous example we have seen how to configure log4j2 for Java, Spring and Spring Boot applications but here we will control multiple log…

Continue

How to configure log4j2 in Java, Spring and Spring Boot Applications

Introduction In this tutorial I will show you how to configure log4j2 in Java, Spring and Spring Boot applications. The same log4j2 configuration will work for Java, Spring and Spring Boot applications. I am not going to show you how to use logback API in Spring Boot application, instead I will exclude logback API from the Spring Boot application. I am going to use log4j2 with slf4j for Java, Spring and Spring Boot applications. You can even use spring-boot-starter-log4j2 API instead of log4j2 with slf4j for Spring Boot application. This…

Continue

Spring Data JPA CRUD Example

Introduction In this tutorial I will show you an example on Spring Data JPA CRUD. Here I will use the embedded or in-memory HSQL database. CRUD means Create, Read, Update, Delete. So I am going to perform basic CRUD operations on some entities. In this example I will create annotation based Spring standalone application. Related Posts: Embedded HSQL Database in Spring Application Spring Boot Data JPA CRUD Example

Continue

Logging Configuration in Spring Boot

Introduction In this tutorial I will show you how logging configuration in Spring Boot applications by overriding Spring Boot’s default logging mechanism by creating logback.xml file under src/main/resources directory. You may also read Simple log4j configuration in java and Log4j Configurations – Controlling Logging to Multiple Files By default, slf4j logging is already included in the Spring Boot application, you just need to enable it. To enable logging, create a application.properties file in the root of the src/main/resources folder.

Continue

Log4j Configurations – Controlling Logging to Multiple Files

Introduction The purpose of inserting log statements into the code is a low-tech method for debugging it. It may also be the only way because debuggers are not always available or applicable. This is often the case for distributed applications. Features of Log4j We can enable logging at runtime without modifying the application binary. We can control the behavior of logging by editing only the configuration file, no need to touch the application binary. Developer are always clear with detailed context for application failures. Log4j has one of the distinctive…

Continue

Append-String Transformer in Mule ESB

What is Mule ESB ? Mule ESB is a lightweight Java-based enterprise service bus (ESB) and integration platform that allows developers to connect applications together quickly and easily, enabling them to exchange data. Mule ESB enables easy integration of existing systems, regardless of the different technologies that the applications use, including JMS, Web Services, JDBC, HTTP, and more. This example shows how we can read a file from a source directory and append a string to the file content and display it into the console. We simply put a file…

Continue