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}对应当前应用根目录;

 

相关文章:

  • 2022-12-23
  • 2021-10-26
  • 2022-12-23
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
  • 2021-07-09
  • 2022-01-30
猜你喜欢
  • 2022-01-17
  • 2021-06-24
  • 2021-10-12
  • 2021-07-05
  • 2022-01-26
  • 2022-12-23
相关资源
相似解决方案