public class Log4JProvider extends java.lang.Object implements LogProvider
LogProvider that uses Categories of Log4J, see the Log4J website for more details.
There are corresponding methods for isDebugEnabled() , isInfoEnabled() etc. to save the overhead of building the log string if the appropriate level is not set, as follows:
if ( logger.isInfoEnabled() ) logger.info( "This " + methodCall() + " and the string " + "concatenation will only take place if " + "INFO debugging is currently enabled" );
A configuration file should be used by setting the
logger.config
system property which will be processed
using PropertyConfigurator.
Constructor and Description |
---|
Log4JProvider() |
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Shutdown Provider.
|
java.lang.Object |
getContext(java.lang.String name)
Get object representing context of logger.
|
void |
init()
Setup Configurator.
|
boolean |
isEnabled(java.lang.Object context,
int level)
Check whether logging is enabled for particular context/level combination.
|
void |
log(java.lang.Object context,
int level,
java.lang.Object msg,
java.lang.Throwable throwable)
Log a message.
|
public java.lang.Object getContext(java.lang.String name)
LogProvider
getContext
in interface LogProvider
public boolean isEnabled(java.lang.Object context, int level)
LogProvider
isEnabled
in interface LogProvider
public void destroy()
Provider
public void init() throws ProviderConfigurationException
init
in interface Provider
ProviderConfigurationException
- thrown if error in startup
or configuration.public void log(java.lang.Object context, int level, java.lang.Object msg, java.lang.Throwable throwable)
LogProvider
log
in interface LogProvider