# Set the priority for the root logger log4j.rootLogger=INFO, stdout # Configure the stdout appender log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%-5p %d{ISO8601} [%t] %c: %m%n # Set the level for the com.example package to DEBUG log4j.logger.com.example=DEBUG import org.apache.log4j.Logger; public class MyApp { private static final Logger logger = Logger.getLogger(MyApp.class); public static void main(String[] args) { org.apache.log4j.PropertyConfigurator.configure("log4j.properties"); logger.debug("Debug message"); logger.info("Info message"); logger.warn("Warn message"); logger.error("Error message"); } }


上一篇:
下一篇:
切换中文