log4j2.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- OFF < FATAL < ERROR < WARN < INFO < DEBUG < TRACE < ALL --> <configuration status="DEBUG"> <Properties> <Property name="LOG_HOME">logs</Property> <Property name="LOG_NAME">log</Property> </Properties> <appenders> <Console name="Console" target="SYSTEM_OUT"> <PatternLayout charset="UTF-8" pattern="%d{yyyy-MM-dd HH:mm:ss} %-5level [%thread][%file:%line] - %msg%n" /> </Console> <RollingFile name="log" fileName="${LOG_HOME}/${LOG_NAME}.log" filePattern="${LOG_HOME}/${LOG_NAME}.%d{yyyy-MM-dd}.log" append="true"> <PatternLayout charset="UTF-8" pattern="%d{yyyy-MM-dd HH:mm:ss} %-5level [%thread][%file:%line] - %msg%n" /> <Policies> <TimeBasedTriggeringPolicy modulate="true" interval="1" /> </Policies> <DefaultRolloverStrategy max="180" /> </RollingFile> </appenders> <loggers> <root level="INFO"> <appender-ref ref="Console" /> <appender-ref ref="log" /> </root> </loggers> </configuration>
值得一提,Sublime 3 Text这个文本编辑器可以实时反映log文件的变更,以至于可以不用再看eclipse里面的consolo了