Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The Log4j logger is used in MagicDraw and other modeling tools developed by No Magic IncOur modeling tools, including MagicDraw, use the Log4j logger. The configuration file is <program installation directory>/data/debug.properties.

Note

The <program installation directory>/data/test.properties 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.

Code Block
languagetext
    log4j.appender.SO=org.apache.log4j.ConsoleAppender 
    log4j.appender.SO.layout=org.apache.log4j.PatternLayout 
    log4j.appender.SO.layout.ConversionPattern=%d [%t] %-5p %c - %m%n 
    log4j.rootCategory=INFO,SO


The example below displays how information can be logged to the configured log file:

Code Block
languagetext
//used to get logger with category name
org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger("GENERAL");

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] INFO  GENERAL - Logging info
//0000-00-00 00:00:00,000 [THREAD] ERROR GENERAL - Logging error


More information about Log4j can be found at http://logging.apache.org/log4j/1.2/.