Package org.apache.ignite.logger.log4j2
Class Log4J2Logger
- java.lang.Object
- 
- org.apache.ignite.logger.log4j2.Log4J2Logger
 
- 
- All Implemented Interfaces:
- IgniteLogger,- org.apache.ignite.internal.logger.IgniteLoggerEx
 
 public class Log4J2Logger extends Object implements org.apache.ignite.internal.logger.IgniteLoggerEx Log4j2-based implementation for logging. This logger should be used by loaders that have prefer log4j2-based logging.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-log4j.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 LoggerResourceannotation about logger injection.
- 
- 
Field Summary- 
Fields inherited from interface org.apache.ignite.IgniteLoggerDEV_ONLY
 
- 
 - 
Constructor SummaryConstructors Constructor Description Log4J2Logger()Creates new logger and automatically detects if root logger already has appenders configured.Log4J2Logger(File cfgFile)Creates new logger with given configurationcfgFile.Log4J2Logger(String path)Creates new logger with given configurationpath.Log4J2Logger(URL cfgUrl)Creates new logger with given configurationcfgUrl.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConsoleAppender(boolean clearOutput)Adds console appender to the logger.org.apache.logging.log4j.LoggerconfigureConsoleAppender(boolean clearOutput)Creates console appender with some reasonable default logging settings.voiddebug(@Nullable String marker, String msg)Logs out debug message.voiddebug(String msg)Logs out debug message.voiderror(@Nullable String marker, String msg, @Nullable Throwable e)Logs error message with optional exception.voiderror(String msg, @Nullable Throwable e)Logs error message with optional exception.@Nullable StringfileName()Gets name of the file being logged to if one is configured ornullotherwise.voidflush()Flush any buffered output.Log4J2LoggergetLogger(Object ctgr)GetsIgniteLoggerwrapper around log4j logger for the given category.voidinfo(@Nullable String marker, String msg)Logs out information message.voidinfo(String msg)Logs out information message.static booleanisConfigured()Checks if Log4j is already configured within this VM or not.booleanisDebugEnabled()Tests whetherdebuglevel is enabled.booleanisInfoEnabled()Tests whetherinfolevel is enabled.booleanisQuiet()Tests whether Logger is in "Quiet mode".booleanisTraceEnabled()Tests whethertracelevel is enabled.voidsetApplicationAndNode(@Nullable String application, @Nullable UUID nodeId)Sets application name and node ID.StringtoString()voidtrace(@Nullable String marker, String msg)Logs out trace message.voidtrace(String msg)Logs out trace message.voidwarning(@Nullable String marker, String msg, @Nullable Throwable e)Logs out warning message with optional exception.voidwarning(String msg, @Nullable Throwable e)Logs out warning message with optional exception.- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface org.apache.ignite.IgniteLoggererror, warning
 
- 
 
- 
- 
- 
Constructor Detail- 
Log4J2Loggerpublic Log4J2Logger() Creates new logger and automatically detects if root logger already has appenders configured. If it does not, the root logger will be configured with default appender, otherwise, existing appenders will be used.
 - 
Log4J2Loggerpublic Log4J2Logger(String path) throws IgniteCheckedException Creates new logger with given configurationpath.- Parameters:
- path- Path to log4j2 configuration XML file.
- Throws:
- IgniteCheckedException- Thrown in case logger can't be created.
 
 - 
Log4J2Loggerpublic Log4J2Logger(File cfgFile) throws IgniteCheckedException Creates new logger with given configurationcfgFile.- Parameters:
- cfgFile- Log4j configuration XML file.
- Throws:
- IgniteCheckedException- Thrown in case logger can't be created.
 
 - 
Log4J2Loggerpublic Log4J2Logger(URL cfgUrl) throws IgniteCheckedException Creates new logger with given configurationcfgUrl.- Parameters:
- cfgUrl- URL for Log4j configuration XML file.
- Throws:
- IgniteCheckedException- Thrown in case logger can't be created.
 
 
- 
 - 
Method Detail- 
fileName@Nullable public @Nullable String fileName() Gets name of the file being logged to if one is configured ornullotherwise.- Specified by:
- fileNamein interface- IgniteLogger
- Returns:
- Name of the file being logged to if one is configured or nullotherwise.
 
 - 
addConsoleAppenderpublic void addConsoleAppender(boolean clearOutput) Adds console appender to the logger.- Specified by:
- addConsoleAppenderin interface- org.apache.ignite.internal.logger.IgniteLoggerEx
- Parameters:
- clearOutput- If- truethen console output must be configured without any additional info like time, message level, thread info, etc.
 
 - 
flushpublic void flush() Flush any buffered output.- Specified by:
- flushin interface- org.apache.ignite.internal.logger.IgniteLoggerEx
 
 - 
configureConsoleAppenderpublic org.apache.logging.log4j.Logger configureConsoleAppender(boolean clearOutput) Creates console appender with some reasonable default logging settings.- Parameters:
- clearOutput- If- truethen console output must be configured without any additional info like time, message level, thread info, etc.
- Returns:
- Logger with auto configured console appender.
 
 - 
isConfiguredpublic static boolean isConfigured() Checks if Log4j is already configured within this VM or not.- Returns:
- Trueif log4j was already configured,- falseotherwise.
 
 - 
setApplicationAndNodepublic void setApplicationAndNode(@Nullable @Nullable String application, @Nullable @Nullable UUID nodeId)Sets application name and node ID.- Specified by:
- setApplicationAndNodein interface- org.apache.ignite.internal.logger.IgniteLoggerEx
- Parameters:
- application- Application.
- nodeId- Node ID.
 
 - 
getLoggerpublic Log4J2Logger getLogger(Object ctgr) GetsIgniteLoggerwrapper around log4j logger for the given category. If category isnull, then root logger is returned. If category is an instance ofClassthen(Class)ctgr).getName()is used as category name.- Specified by:
- getLoggerin interface- IgniteLogger
- Parameters:
- ctgr- Category for new logger.
- Returns:
- IgniteLoggerwrapper around log4j logger.
 
 - 
tracepublic void trace(String msg) Logs out trace message.- Specified by:
- tracein interface- IgniteLogger
- Parameters:
- msg- Trace message.
 
 - 
tracepublic void trace(@Nullable @Nullable String marker, String msg)Logs out trace message. The default implementation callsthis.trace(msg).- Specified by:
- tracein interface- IgniteLogger
- Parameters:
- marker- Name of the marker to be associated with the message.
- msg- Trace message.
 
 - 
debugpublic void debug(String msg) Logs out debug message.- Specified by:
- debugin interface- IgniteLogger
- Parameters:
- msg- Debug message.
 
 - 
debugpublic void debug(@Nullable @Nullable String marker, String msg)Logs out debug message. The default implementation callsthis.debug(msg).- Specified by:
- debugin interface- IgniteLogger
- Parameters:
- marker- Name of the marker to be associated with the message.
- msg- Debug message.
 
 - 
infopublic void info(String msg) Logs out information message.- Specified by:
- infoin interface- IgniteLogger
- Parameters:
- msg- Information message.
 
 - 
infopublic void info(@Nullable @Nullable String marker, String msg)Logs out information message. The default implementation callsthis.info(msg).- Specified by:
- infoin interface- IgniteLogger
- Parameters:
- marker- Name of the marker to be associated with the message.
- msg- Information message.
 
 - 
warningpublic void warning(String msg, @Nullable @Nullable Throwable e) Logs out warning message with optional exception.- Specified by:
- warningin interface- IgniteLogger
- Parameters:
- msg- Warning message.
- e- Optional exception (can be- null).
 
 - 
warningpublic void warning(@Nullable @Nullable String marker, String msg, @Nullable @Nullable Throwable e)Logs out warning message with optional exception. The default implementation callsthis.warning(msg).- Specified by:
- warningin interface- IgniteLogger
- Parameters:
- marker- Name of the marker to be associated with the message.
- msg- Warning message.
- e- Optional exception (can be- null).
 
 - 
errorpublic void error(String msg, @Nullable @Nullable Throwable e) Logs error message with optional exception.- Specified by:
- errorin interface- IgniteLogger
- Parameters:
- msg- Error message.
- e- Optional exception (can be- null).
 
 - 
errorpublic void error(@Nullable @Nullable String marker, String msg, @Nullable @Nullable Throwable e)Logs error message with optional exception. The default implementation callsthis.error(msg).- Specified by:
- errorin interface- IgniteLogger
- Parameters:
- marker- Name of the marker to be associated with the message.
- msg- Error message.
- e- Optional exception (can be- null).
 
 - 
isTraceEnabledpublic boolean isTraceEnabled() Tests whethertracelevel is enabled.- Specified by:
- isTraceEnabledin interface- IgniteLogger
- Returns:
- truein case when- tracelevel is enabled,- falseotherwise.
 
 - 
isDebugEnabledpublic boolean isDebugEnabled() Tests whetherdebuglevel is enabled.- Specified by:
- isDebugEnabledin interface- IgniteLogger
- Returns:
- truein case when- debuglevel is enabled,- falseotherwise.
 
 - 
isInfoEnabledpublic boolean isInfoEnabled() Tests whetherinfolevel is enabled.- Specified by:
- isInfoEnabledin interface- IgniteLogger
- Returns:
- truein case when- infolevel is enabled,- falseotherwise.
 
 - 
isQuietpublic boolean isQuiet() Tests whether Logger is in "Quiet mode".- Specified by:
- isQuietin interface- IgniteLogger
- Returns:
- true"Quiet mode" is enabled,- falseotherwise
 
 
- 
 
-