0
votes

I use Log4J to log application runtime process. Here is my log4j.properties file:

log4j.rootLogger=INFO, DailyRollingFile
log4j.appender.DailyRollingFile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.DailyRollingFile.File=${CATALINA_HOME}/logs/fnservice.log
log4j.appender.DailyRollingFile.append = true
log4j.appender.DailyRollingFile.DatePattern='.'yyyy-MM-dd
log4j.appender.DailyRollingFile.layout=org.apache.log4j.PatternLayout
log4j.appender.DailyRollingFile.layout.ConversionPattern=%d{HH:mm:ss} %-5p %t %c{1} %M:%L - %m%n'

I have deployed application on Tomcat and invoked some it's methods to get log messages. After these manipulations, into ${CATALINA_HOME}/logs folder I got a few .log files:

  1. catalina.2017-02-12.log; (no my app messages)
  2. catalina.out; (no my app messages)
  3. host-manager.2017-02-12.log; (emply)
  4. localhost.2017-02-12.log; (no my app messages)
  5. localhost_access_log.2017-02-11.txt; (no my app messages)
  6. manager.2017-02-11.log. (empty)

In my application I get loggers as:

//the code inside the MyClass class
Logger LOG = Logger.getLogger(MyClass.class);

Also I try to log messages with INFO and ERROR level.

As a result I get listed files and no one contains my log messages. And it seems that rolling does not work too.

1
I solved the issue by interchanging a line in my log4j.properties by log4j.appender.DailyRollingFile.File=${catalina.home}/logs/fnservice.log But I have got another question: If I deploy my app on WebSphere, It will be necessary to fix log4j.properties file. How could I set my log4j to be platform-independent? Thank you.Alexander Belenov

1 Answers

0
votes

I solved the issue by interchanging a line in my log4j.properties by

log4j.appender.DailyRollingFile.File=${catalina.home}/logs/f‌​nservice.log