Logging levels in log4j

Logging levels: All logging levels are defined in the org.apache.log4j.Level class. We can also create our own levels. Logging levels are given below: 1. ALL: All levels including custom levels also. 2. DEBUG: It helps developers in application debugging. 3. INFO: It gives the information about the progress of application and its states. 4. WARN: … Read more

Log4j example using log4j xml file

We can also use an xml file named log4j.xml to configure the Log4j. Let us discuss the use of log4j.xml configuration file with the help of below example. Example: Log4jTest.java import org.apache.log4j.Logger;   /** * This class is used to show the use of * Log4j with the log4j.xml file. * @author w3schools */ public … Read more

Log4j example using log4j properties file

Let us discuss the use of Log4j with the help of below example. In this example we use log4j.properties file for Log4j configurations. Example: Log4jTest.java import org.apache.log4j.Logger;   /** * This class is used to show the use of * Log4j with the log4j.properties file. * @author w3schools */ public class Log4jTest { //Get the … Read more

Java Log4j example

Let us discuss the use of Log4j with the help of below example. In this example we use BasicConfigurator for Log4j configurations. BasicConfigurator use ConsoleAppender and PatternLayout for all loggers. Example: Log4jTest: import org.apache.log4j.BasicConfigurator; import org.apache.log4j.Logger;   /** * This class is used to show the use of * Log4j with the BasicConfigurator. * @author … Read more

Log4j Logger class

Logger class: Logger class provides the methods for logging process. We can use the getLogger() method to get the Logger object. Syntax: public static Logger getLogger(String name); Where name is the fully qualified class name. Logging methods: 1. debug(Object message): It is used to print the message with the level Level.DEBUG. Syntax: public void debug(Object … Read more

Generics constructor

A constructor can be declared as generic, independently of whether the class that the constructor is declared in is itself generic. A constructor is generic if it declares one or more type variables. These type variables are known as the formal type parameters of the constructor. The form of the formal type parameter list is … Read more

Generics method in java

The methods which can handle different types of arguments are known as generic methods. Types of the argument are specified on method call. Syntax: generic method includes a type parameter, inside angle brackets and appears before the method’s return type. public static <T> T identical(T obj){ return returnValue; }public static <T> T identical(T obj){ return … Read more

Generics class Java

Generic classes/interfaces have the class name followed by a type parameter section. Type parameter section of can have one or more type parameters separated by commas. These classes/interfaces are known as parameterized classes/interfaces. Example: GenericsTest.java /** * This class is used to show the use generics class. * @author w3schools */ class Test<T> { private … Read more

Lower bounded wildcard in generics

Lower bounded wildcard: Java generics lower bounded wildcard : Lower bounded wildcard is used to restrict the unknown type to be a specific type or a super type of that type using ‘?’ with super keyword. Syntax: Collectiontype <? super T> Let us consider that we want to write a method which prints list items … Read more

Upper bounded wildcard in generics

Upper bounded wildcard: Java generics upper bounded wildcard : Upper bounded wildcard is used to restrict the unknown type to be a specific type or a subtype of that type using ‘?’ with extends keyword. Syntax: Collectiontype<? extends T> Let us consider that we want to write a method which prints square of each number … Read more