log4j

All

Intro

One log framework to rule them all.

log4j

log4j is a reliable, fast and flexible logging framework (APIs) written in Java.

pom.xml

<dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency>

Main components [1]

  • loggers: Responsible for capturing logging information.
  • appenders: Responsible for publishing logging information to various preferred destinations.
  • layouts: Responsible for formatting logging information in different styles.

 

Example

//logs an error message with parameter
	logger.error("This is error : " + parameter);
	
	//logs an exception thrown from somewhere
	logger.error("This is error", exception);

REFs

[1] https://www.tutorialspoint.com/log4j/log4j_overview.htm

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s