MyBatis Generator (MBG) reports logging information in several different ways:
In general, MBG will not repeat messages. So if MBG generates a warning, that warning is typically not also logged. In some situations it may be useful to enable logging as well as asking MBG to be verbose with progress messages. This may generate a substantial output, but it will also give a very complete picture of what's happening internally during the MBG run.
MBG will use Apache Log4J logging if Log4J is in the runtime classpath. See http://logging.apache.org/log4j/ for more information about Log4J. If Log4J is not in the runtime classpath, MBG will use standard Java logging.
If for any reason you prefer to force the use of standard Java logging, even if Log4J is in the runtime classpath, you may specify the -forceJavaLogging command line argument, or specify the following line of code when running MBG from Java:
org.mybatis.generator.logging.LogFactory.forceJavaLogging();
Important: You should specify the above line of code before any other MBG code.
If you prefer to use a different logging implementation than Log4J or standard Java logging, you may supply an alternate implementation of the key logging interfaces as follows:
The following is a sample Log4J configuration file:
# Set root logger log4j.rootLogger=INFO, A1 # A1 is set to be a ConsoleAppender. log4j.appender.A1=org.apache.log4j.ConsoleAppender log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%-4r %-5p %c - %m%n # MBG logging configuration... log4j.logger.org.mybatis.generator=DEBUG
This file will instruct Log4J to write all MBG debug messages to the console. To use this file:
You should see many log messages in the console.
You may also configure Log4J in any of the other supported methods if you prefer.
The following is a sample Java logging configuration file:
# Specify the handlers to create in the root logger # (all loggers are children of the root logger) handlers = java.util.logging.ConsoleHandler # Set the default logging level for the root logger .level = INFO # Set the default logging level for new ConsoleHandler instances java.util.logging.ConsoleHandler.level = ALL # Set the default formatter for new ConsoleHandler instances java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter # Set the default logging level for the logger named org.mybatis.generator org.mybatis.generator.level = FINE
This file will instruct Java to write all MBG debug messages to the console. To use this file:
You should see many log messages in the console.
You may also configure Java logging in any of the other supported methods if you prefer.