public class Log4J2Logger extends Object implements IgniteLogger, LoggerNodeIdAware
Here is a typical example of configuring log4j2 logger in Ignite configuration file:
<property name="gridLogger">
<bean class="org.apache.ignite.logger.log4j2.Log4J2Logger">
<constructor-arg type="java.lang.String" value="config/ignite-log4j2.xml"/>
</bean>
</property>
and from your code:
IgniteConfiguration cfg = new IgniteConfiguration();
...
URL xml = U.resolveIgniteUrl("config/custom-log4j2.xml");
IgniteLogger log = new Log4J2Logger(xml);
...
cfg.setGridLogger(log);
Please take a look at Apache Log4j 2
for additional information.
It's recommended to use Ignite logger injection instead of using/instantiating
logger in your task/job code. See LoggerResource annotation about logger
injection.
| Constructor and Description |
|---|
Log4J2Logger(File cfgFile)
Creates new logger with given configuration
cfgFile. |
Log4J2Logger(String path)
Creates new logger with given configuration
path. |
Log4J2Logger(URL cfgUrl)
Creates new logger with given configuration
cfgUrl. |
| Modifier and Type | Method and Description |
|---|---|
static org.apache.logging.log4j.core.Logger |
createConsoleLogger()
Creates console appender with some reasonable default logging settings.
|
void |
debug(String msg)
Logs out debug message.
|
void |
error(String msg)
Logs out error message.
|
void |
error(String msg,
Throwable e)
Logs error message with optional exception.
|
String |
fileName()
Gets name of the file being logged to if one is configured or
null otherwise. |
Log4J2Logger |
getLogger(Object ctgr)
Gets
IgniteLogger wrapper around log4j logger for the given
category. |
UUID |
getNodeId()
Gets node ID.
|
void |
info(String msg)
Logs out information message.
|
boolean |
isDebugEnabled()
Tests whether
debug level is enabled. |
boolean |
isInfoEnabled()
Tests whether
info level is enabled. |
boolean |
isQuiet()
Tests whether
info and debug levels are turned off. |
boolean |
isTraceEnabled()
Tests whether
trace level is enabled. |
void |
setLevel(org.apache.logging.log4j.Level level)
Sets level for internal log4j implementation.
|
void |
setNodeId(UUID nodeId)
Sets node ID.
|
String |
toString() |
void |
trace(String msg)
Logs out trace message.
|
void |
warning(String msg)
Logs out warning message.
|
void |
warning(String msg,
Throwable e)
Logs out warning message with optional exception.
|
public Log4J2Logger(String path) throws IgniteCheckedException
path.path - Path to log4j configuration XML file.IgniteCheckedException - Thrown in case logger can't be created.public Log4J2Logger(File cfgFile) throws IgniteCheckedException
cfgFile.cfgFile - Log4j configuration XML file.IgniteCheckedException - Thrown in case logger can't be created.public Log4J2Logger(URL cfgUrl) throws IgniteCheckedException
cfgUrl.cfgUrl - URL for Log4j configuration XML file.IgniteCheckedException - Thrown in case logger can't be created.public void setLevel(org.apache.logging.log4j.Level level)
level - Log level to set.@Nullable public String fileName()
null otherwise.fileName in interface IgniteLoggernull otherwise.public static org.apache.logging.log4j.core.Logger createConsoleLogger()
public void setNodeId(UUID nodeId)
setNodeId in interface LoggerNodeIdAwarenodeId - Node ID.public UUID getNodeId()
getNodeId in interface LoggerNodeIdAwarepublic Log4J2Logger getLogger(Object ctgr)
IgniteLogger wrapper around log4j logger for the given
category. If category is null, then root logger is returned. If
category is an instance of Class then (Class)ctgr).getName()
is used as category name.getLogger in interface IgniteLoggerctgr - Category for new logger.IgniteLogger wrapper around log4j logger.public void trace(String msg)
trace in interface IgniteLoggermsg - Trace message.public void debug(String msg)
debug in interface IgniteLoggermsg - Debug message.public void info(String msg)
info in interface IgniteLoggermsg - Information message.public void warning(String msg)
warning in interface IgniteLoggermsg - Warning message.public void warning(String msg, @Nullable Throwable e)
warning in interface IgniteLoggermsg - Warning message.e - Optional exception (can be null).public void error(String msg)
error in interface IgniteLoggermsg - Error message.public void error(String msg, @Nullable Throwable e)
error in interface IgniteLoggermsg - Error message.e - Optional exception (can be null).public boolean isTraceEnabled()
trace level is enabled.isTraceEnabled in interface IgniteLoggertrue in case when trace level is enabled, false otherwise.public boolean isDebugEnabled()
debug level is enabled.isDebugEnabled in interface IgniteLoggertrue in case when debug level is enabled, false otherwise.public boolean isInfoEnabled()
info level is enabled.isInfoEnabled in interface IgniteLoggertrue in case when info level is enabled, false otherwise.public boolean isQuiet()
info and debug levels are turned off.isQuiet in interface IgniteLoggerinfo and debug levels are turned off.
Follow @ApacheIgnite
Ignite Fabric : ver. 1.5.11 Release Date : April 8 2016