What is Log4j?
It is an open source
logging tool, given by apache to use as an
alternative for System.out.println (““) statements
in a java project.
It has 3 main components to work with Log4j
1)
Logger Object
2)
Appender Object
3)
Layout Object
Logger:
Logger Object is responsible for capturing logging messages
generated at execution time of an application.
•
Logger
is a class, in org.apache.log4j.*
•
We
need to create Logger object one per java class.
•
Logger class
methods are used to generate log statements
in a java class instead of System.out.println(“”) statements;
static Logger logger=Logger.getLogger
(String classname);
static Logger logger=Logger.getLogger
(Class clazz);
getLogger () method is a static factory methods
.its returns a class object.
Logger
object has some methods; actually we used to print the status of our
application by using these methods only
We
have a method in Logger class
•
debug()
•
info()
•
warn()
•
error()
•
fetal()
As
a programmer it’s our responsibility to know
where we need to use what method.
Good but not sufficient to work with log4j
ReplyDelete