log4j配置文件中路径配置一般有三种方法:

 log4j配置文件中路径配置一般有三种方法:

 

(1)绝对路径法:直接配置为系统觉得路径;

 

(2)相对路径法:

 

log4j.appender.logfile.File=../logs/app.log,将日志记录到tomcat下的logs文件夹;

 

log4j.appender.logfile.File=logs/app.log,将日志记录到tomcat的bin目录下的logs文件夹;

 

(3)使用环境变量相对路径法:程序会优先找jvm环境变量,然后再找系统环境变量,来查找配置文件中的变量。

 

log4j.appender.logfile.File=${user.dir}/logs/app.log,使用tomcat容器时${user.dir}对应tomcat的bin目录;

 

log4j.appender.logfile.File=${user.home}/logs/app.log,${user.home}对应操作系统当前用户目录;

 

log4j.appender.logfile.File=${webApp.root}/logs/app.log,${webApp.root}对应当前应用根目录;

 

posted @ 2019-04-19 17:19  滤v镜  阅读(1329)  评论(0编辑  收藏  举报