Reputation: 1328
I have a few question to ask about implementing logger with log4j2 .
Is log4j2
still in beta
release stage ? If so any idea when will
final release happen ?
I noticed there are quite few changes that needs to be done with
migrating from log4j1.2
to log4j2
. So one particular change i
am conserned with is the following
Logger.getLogger must be modified to LogManager.getLogger
.
So if this is a change then I have to change the static instance such as
private static Logger logger = Logger.getLogger( MyClass.class )
to
private static Logger logger = LogManager.getLogger( MyClass.class )
right?
3.Is there way to write a custom class to call Logger.getLogger()
and call this custom method in every class for instantiating ?
-Sam
Upvotes: 1
Views: 937
Reputation: 1609
1) As far as I know, future development of log4j is dropped.
The next project is slf4j, which is an abstract logger, with the default implementation logback.
2) I don't know if this change is needed, because I use slf4j now.
3) Why do that.. It's only 1 line for the logger object creation. But it is possible yes.
class MyLoggerFactory {
public static Logger getLogger (Class clazz){
return Logger.getLogger(clazz);
}
}
And called with MyLoggerFactory.getLogger(this.class);
or something similar. I don't have an IDE right now.
Upvotes: 1