Package apps.util
Class Log4JUtil
- java.lang.Object
-
- apps.util.Log4JUtil
-
public class Log4JUtil extends java.lang.Object
Common utility methods for working with Log4J.Two system properties influence how logging is configured in JMRI:
- jmri.log
- The logging control file. If this file is not an
absolute path, this file is searched for in the following order:
- JMRI settings directory
- JMRI installation (program) directory
- jmri.log.path
- The directory for storing logs. If not specified, logs are stored in the JMRI preferences directory.
See also jmri.util.TestingLoggerConfiguration in the Test code for Tests Logging Setup.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_LCF_NAMEstatic java.lang.StringSYS_PROP_LCF_LOCATIONstatic java.lang.StringSYS_PROP_LOG_PATH
-
Constructor Summary
Constructors Constructor Description Log4JUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringgetLoggingConfig(java.lang.String logFileLocation)(package private) static voidinitializeJavaUtilLogging()(package private) static voidinitLog4J(java.lang.String logFile)Initialize Log4J.static voidinitLogging()Initialize logging from a default control file.static voidinitLogging(java.lang.String controlfile)Initialize logging, specifying a control file.static java.lang.StringstartupInfo(java.lang.String program)
-
-
-
Field Detail
-
DEFAULT_LCF_NAME
public static final java.lang.String DEFAULT_LCF_NAME
- See Also:
- Constant Field Values
-
SYS_PROP_LCF_LOCATION
public static final java.lang.String SYS_PROP_LCF_LOCATION
- See Also:
- Constant Field Values
-
SYS_PROP_LOG_PATH
public static final java.lang.String SYS_PROP_LOG_PATH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Log4JUtil
public Log4JUtil()
-
-
Method Detail
-
initLogging
public static void initLogging()
Initialize logging from a default control file.Primary functions:
- Initialize the JMRI System Console.
- Set up the slf4j j.u.logging to log4J bridge.
- Start log4j.
- Initialize a default exception handler.
-
initLogging
public static void initLogging(@Nonnull java.lang.String controlfile)
Initialize logging, specifying a control file.Generally, only used for unit testing. Much better to use allow this class to find the control file using a set of conventions.
- Parameters:
controlfile- the logging control file
-
initLog4J
static void initLog4J(@Nonnull java.lang.String logFile)
Initialize Log4J.Use the logging control file specified in the jmri.log property or, if none, the default_lcf.xml file. If the file is absolute and cannot be found, look for the file first in the settings directory and then in the installation directory.
- Parameters:
logFile- the logging control file- See Also:
FileUtil.getPreferencesPath(),FileUtil.getProgramPath()
-
getLoggingConfig
@CheckForNull public static java.lang.String getLoggingConfig(@Nonnull java.lang.String logFileLocation)
-
initializeJavaUtilLogging
static void initializeJavaUtilLogging()
-
startupInfo
@Nonnull public static java.lang.String startupInfo(@Nonnull java.lang.String program)
-
-