In this post i will discuss about Log4J and Log files.
Log file is just simple file, which keep track of the record or event or info when any event happens or any software run. This whole process known as logging. We can create log file as simple log file.
Why Log file is required:
We can create log file for our simple script also so we can track or debug our script easily if anything goes wrong in script. For example, if our script is failing at some point then we can track back what went wrong
What is log4J
Log4j is free open source tool for creating log files It help us to generate log file.
Log4j is very lightweight and simple logging framework, comprising of three main components
Loggers
Appenders
Layouts
Download Log4J jar file.
1. Navigate to http://mvnrepository.com/
2. Search for Log4J
3. Download latest version of log4J
Create a Class file with below log levels:
logger.debug("Sample debug message");
logger.info("Sample info message");
logger.warn("Sample warn message");
logger.error("Sample error message");
logger.fatal("Sample fatal message");
Below is the sample code:
After executing test you can see logs in log4j.log file and in console as well.
OUTPUT of Log4J file:
Log file is just simple file, which keep track of the record or event or info when any event happens or any software run. This whole process known as logging. We can create log file as simple log file.
Why Log file is required:
We can create log file for our simple script also so we can track or debug our script easily if anything goes wrong in script. For example, if our script is failing at some point then we can track back what went wrong
What is log4J
Log4j is free open source tool for creating log files It help us to generate log file.
Log4j is very lightweight and simple logging framework, comprising of three main components
Loggers
Appenders
Layouts
Download Log4J jar file.
1. Navigate to http://mvnrepository.com/
2. Search for Log4J
3. Download latest version of log4J
Create a sample Java project and add log4J. jar file to project.
Create a properties file
Right click on Project --New --File
give a name log4j.properties.
and add below code in that file
Create a Class file with below log levels:
logger.debug("Sample debug message");
logger.info("Sample info message");
logger.warn("Sample warn message");
logger.error("Sample error message");
logger.fatal("Sample fatal message");
Below is the sample code:
After executing test you can see logs in log4j.log file and in console as well.
OUTPUT of Log4J file:
really informative blog you have posted. i have ever seen such kind of article. so keep on sharing such kind of an interesting article.
ReplyDeleteselenium training in chennai
we are the leading oracle fusion financials training institutes search engine.
ReplyDeletewe have huge database regarding oracle institutions present in india. we can provide
complete institute details as we don't have money charge policy for the information
provided
Oracle fusion Financials Online Training in Ameerpet
Oracle Fusion Financials Training in Ameerpet
nike outlet store
ReplyDeletepandora outlet
michael kors outlet online
cheap nike shoes
pandora
michael kors outlet clearance
michael kors outlet
polo ralph lauren
canada goose jackets
ray ban sunglasses
ReplyDeleteIt's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command.
software testing course in chennai
I have read your blog and i got a very useful and knowledgeable information from your blog.You have done a great job .Please visit our page Selenium Training in Chennai | Selenium Training institutes in Chennai
ReplyDeletethank you for sharing nyce information really very nice sap mm training
ReplyDelete
ReplyDeleteشركة نقل عفش من الرياض الى دبي
ارخص شركة نقل اثاث بالدمام ارخص شركة نقل اثاث بالدمام
شركة نقل عفش
شركة نقل اثاث من الرياض الى الاردن
thanks for sharing this information
ReplyDeleteaws training in bangalore
aws training in btm layout
Amazon web services training in bangalore
amazon web services training in btm layout
best AWS Training institute in Bangalore
aws training institutes in bangalore
AWS certification course in BTM Layout
aws certification course in bangalore
thanks for sharing this information
ReplyDeleteBlue Prism Training in Bangalore
Blue Prism Training in BTM
informatica Training in Bangalore
Android Training in Bangalore
MEAN Stack Training in Bangalore
MEAN Stack Training in BTM
RPA Training in Bangalore
RPATraining in BTM
converse outlet
ReplyDeletebalenciaga sneakers
kyrie 5
moncler
converse shoes
louboutin outlet
hermes belt
louboutin
outlet golden goose
retro jordans
i0j17j6y29 r3h86p7x28 e0a60l2o75 u5m01j0v08 t7o08f0x46 e1a71z4l18
ReplyDelete