67,513
社区成员
发帖
与我相关
我的任务
分享
log4j.rootLogger=info,stdout, logfile
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.File=name.log //这里写你需要的输出的文件的名字
log4j.appender.logfile.MaxFileSize=512KB
# Keep three backup files.
log4j.appender.logfile.MaxBackupIndex=3
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n
log4j.logger.com.aspectgaming.peripheral=info
import org.apache.log4j.*;
public class log4jEx{
static Category cat = Category.getInstance(log4jEx.class.getName());
public static void main(String[] args) {
PropertyConfigurator.configure("log4j.properties");
cat.debug("Statt of Main()");
cat.info("INFO");
cat.warn("WARN");
cat.error("ERROR");
}
}