使用java log4j記錄程式log
1.至apache下載2.4.1版本,然後引用到java專案中 2.將下面的XML存成log4j2.XML,存在專案的/SRC/目錄下 <Configuration status="warn"> <Appenders> <Console name="Console" target="SYSTEM_OUT"> <PatternLayout pattern="[%-5p] %d %c - %m%n" /> </Console> <File name="File" fileName="log/my.log"> <PatternLayout pattern="%m%n" /> </File> <RollingFile name="RollingFile" fileName="log/fileAdd.log" filePattern="log/$${date:yyyy-MM}/fileAdd-%d{MM-dd-yyyy}-%i.log.gz"> <PatternLayout pattern="[%-5p] %d %c - %m%n" /> <Policies> <TimeBasedTriggeringPolicy /> <SizeBasedTriggeringPolicy size="10 MB" /> </Policies> <DefaultRolloverStrategy max="20&