Introduction Are you getting logon denied error while starting or deploying your Spring Boot application into Pivotal Cloud Foundry (PCF) cloud environment? Generally, logon denied error occurs while your application is trying to connect to database server. The error you get in your application log is similar to the following error: From the above error…

Posted in Cloud PCF

Fix Oracle Logon Denied Error In Pivotal Cloud Foundry

Introduction Here in this example, I am going to show you how to create Spring Boot profile based logging. For any applications logging is an important things which will help you to debug through your application errors or issues and you can fix them easily by analyzing those errors or issues from the log files….

Posted in Log4J Spring Boot

Spring Boot Profile Based Logging

Introduction Here I am going to build a system to log online user activity in Spring Boot applications using HandlerInterceptor interface. As an application owner you may want to track your user activities, such as, which page they are accessing, from where requests were made to your application, from which pages to which pages they…

Posted in Spring Boot Spring JPA Spring REST

How To Log Online User Activity In Spring Boot Applications

Introduction The ELK Stack is made of three open-source products: 1) Elasticsearch, 2) Logstash, and 3) Kibana. Elasticsearch: It is a NoSQL database which is based on the open-source search engine called Lucene. So Elasticsearch is a search and analytics engine. Logstash: It is a data processing pipeline tool which accepts inputs from (multiple) sources,…

Posted in Log4J Spring Boot

ELK Stack Integration with Spring Boot Applications

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…

Posted in Microservices Spring Boot Spring Cloud

How to Trace Microservices Logs with Spring Cloud Sleuth and Zipkin

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…

Posted in Java Spring Spring Boot

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

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…

Posted in Java Spring Boot

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 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…

Posted in Java Log4J

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

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…

Posted in Java Log4J Spring Spring Boot

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

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…

Posted in Spring Core Spring JPA

Spring Data JPA CRUD Example

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…

Posted in Spring Boot

Logging Configuration in Spring Boot

Log4j is a logging library for Java applications and 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.

Posted in Log4J

Logging Best Practices using Log4j