Skip to main content

Posts

Showing posts from May, 2022

Getting Started With Log4j Logging

Introduction For Java applications, Log4j is a commonly used and trusted logging tool. When an application is deployed to an application server, logging is a must-have feature. In this tutorial, we'll see how to set up Log4j for a simple Java application. You can find all code related to this tutorial inside GitHub project. Why do we need Logging Logging is an important part of the application since it records user actions, input requests and output responses, error messages, and more. This information aids in the understanding of the application both inside and outside of it, as well as providing faster feedback or support for any issues that may occur during the application's execution. Maven configuration Add following dependencies into pom.xml pom.xml <dependencies> <dependency> <groupId> org.apache.logging.log4j </groupId> <artifactId> log4j-api </artifactId> <version> 2.17.2 </version>

Maven : Create JaCoCo Code Coverage Report

Introduction In this tutorial we will see how to setup the JaCoCo plugin to generate a code coverage report for a Maven project. In order to generate a unit test coverage report, we should have sufficient unit test cases in our application. For this tutorial, I am referring to a Maven project which has a string manipulation method. You can find this project at this GitHub location. There are a few steps that need to be taken to produce the report. Install the Maven JaCoCo plugin. Insert the following code into pom.xml. <plugin> <groupId> org.jacoco </groupId> <artifactId> jacoco-maven-plugin </artifactId> <version> 0.8.2 </version> <executions> <execution> <goals> <goal> prepare-agent </goal> </goals> </execution> <execution> <id> report </id> <phase> test <

Subscribe for latest tutorial updates

* indicates required