Our modeling tools, including MagicDraw, use the Log4j logger. The configuration file is <program installation directory>/data/log4j2.xml.
The <program installation directory>/data/log4j2-test.xml file is used as a configuration file for program test cases.
The following sample presents the content of the configuration file. It configures the logger to print INFO category messages to a console with a specific pattern.
The example below displays how information can be logged to the configured log file:
//used to get logger with category name
org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger("GENERAL");
// set thread context values (optional)
ThreadContext.put("id", "My id");
ThreadContext.put("action_name", "My Action");
logger.info("Logging info");
logger.error("Logging error");
//by default the text will be displayed in the form of:
//0000-00-00 00:00:00,000 [THREAD] [My id My Action] INFO GENERAL - Logging info
//0000-00-00 00:00:00,000 [THREAD] [My id My Action] ERROR GENERAL - Logging error