1

I have successfully implemented slf4j-simple library in my project and it is writing successfully on System.out. The only problem is that i can't log into a custom file as it does not recognize the path i defined in simplelogger.properties file.

My simplelogger.properties file looks like this:

# 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

The error i am getting is:

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)

So some how it is unable to identify the ${catalina.base}. I am sure it is not the problem with hist.log file because even if i am replacing the filename, it is still giving me the error.

In order to identify if ${catalina.base} is set. I ran following command:

ps aux | grep catalina

It does show that the -Dcatalina.base=/usr/share/tomcat/

Can't figure out what is wrong with this base path.

Usama Aftab
  • 99
  • 1
  • 14

0 Answers0