首先要导入的包:
import:
每个类中加入下面,其中 RdiFtpDownload.class 是当前的类名.class
然后就可以打日志了:
配置 log4j.properties
log4j.rootLogger=info, stdout, ROLLING_FILE log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=<%d>[%5p] %c - %m%n #log4j.appender.stdout.layout.ConversionPattern=(%8c) %m%n log4j.appender.ROLLING_FILE=org.apache.log4j.RollingFileAppender log4j.appender.ROLLING_FILE.Threshold=INFO log4j.appender.ROLLING_FILE.File=./log/ftpApplication.log log4j.appender.ROLLING_FILE.Append=true log4j.appender.ROLLING_FILE.MaxFileSize=10MB log4j.appender.ROLLING_FILE.MaxBackupIndex=10 log4j.appender.ROLLING_FILE.layout=org.apache.log4j.PatternLayout log4j.appender.ROLLING_FILE.layout.ConversionPattern=<%d>[%5p] %c - %m%n