slf4j-simple无法找到catalina.base

时间:2017-03-09 22:27:29

标签: linux slf4j tomcat8 catalina

我已经在我的项目中成功实现了slf4j-simple库,并且它正在System.out上成功编写。唯一的问题是我无法登录自定义文件,因为它无法识别我在simplelogger.properties文件中定义的路径。

我的simplelogger.properties文件如下所示:

# SLF4J's SimpleLogger configuration file
# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err.

# Default logging detail level for all instances of SimpleLogger.
# Must be one of ("trace", "debug", "info", "warn", or "error").
# If not specified, defaults to "info".
org.slf4j.simpleLogger.defaultLogLevel=info

# Logging detail level for a SimpleLogger instance named "xxxxx".
# Must be one of ("trace", "debug", "info", "warn", or "error").
# If not specified, the default logging detail level is used.
#org.slf4j.simpleLogger.log.xxxxx=

# Set to true if you want the current date and time to be included in output messages.
# Default is false, and will output the number of milliseconds elapsed since startup.
org.slf4j.simpleLogger.showDateTime=true

# The date and time format to be used in the output messages.
# The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat.
# If the format is not specified or is invalid, the default format is used.
# The default format is yyyy-MM-dd HH:mm:ss:SSS Z.
org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS

# Set to true if you want to output the current thread name.
# Defaults to true.
#org.slf4j.simpleLogger.showThreadName=true

# Set to true if you want the Logger instance name to be included in output messages.
# Defaults to true.
org.slf4j.simpleLogger.showLogName=true

# Set to true if you want the last component of the name to be included in output messages.
# Defaults to false.
#org.slf4j.simpleLogger.showShortLogName=false

org.slf4j.simpleLogger.logFile=${catalina.base}/logs/hist.log

我得到的错误是:

java.io.FileNotFoundException: ${catalina.base}/logs/hist.log (No such file or directory)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)

所以有些人无法识别$ {catalina.base}。我确信这不是hist.log文件的问题,因为即使我正在替换文件名,它仍然给我错误。

为了确定是否设置了$ {catalina.base}。我运行了以下命令:

ps aux | grep catalina

确实显示-Dcatalina.base=/usr/share/tomcat/

无法弄清楚此基本路径有什么问题。

0 个答案:

没有答案