2

After migrating my application from spring 1.5.21 to spring 2.0.9 my logfile on actuator/logfile doesn't work properly when user in tomacat 9.

I am using lib "java.util.logging.Level".

A simple:

Logger.getLogger(Classname.class.getName())
                        .log(Level.SEVERE, "Teste: " + variable, ex);

doesn't appear on spring.log file.

This file was configured in a .properties file inside Spring boot project, like this:

logging.path=${user.home}/.path/logs/

But somethings are not stored in the file, by example "SPRING BANNER" or every Logger.getLogger command inside my code.

In spring 1.5.21 appeared everything on spring.log file.

I use the IDE Netbeans, and inside netBeans everything is logged properly. But if I deploy the .war file of my application into Tomcat it doesn't appear on actuator/logfile (Stored on spring.log on path told above).

In my pom.xml I changed of:

 <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.21.RELEASE</version>
    </parent>

to:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.9.RELEASE</version>
    </parent>

Additional information: I Saw that the log instruction appears normally on catalina.out file, but I would like it to work on actuator/logfile;

Can anyone help me with this issue ?

Thank you so much

Helio Leal
  • 21
  • 3

1 Answers1

0

A simple: [snip] doesn't appear on spring.log file.

Loggers are subject to garbage collection. Write your logging statements like:

private static final String CLASS_NAME = Classname.class.getName();
private static final Logger logger = Logger.getLogger(CLASS_NAME);

...

if (logger.isLoggable(Level.SEVERE)) {
   logger.log(Level.SEVERE, "Teste: " + variable, ex);
}

3rd party libs can remove the attached handlers from the loggers. Print the logger tree so you can determine if it is an issue with handlers being removed or a level issue.

I Saw that the log instruction appears normally on catalina.out file, but I would like it to work on actuator/logfile;

The console handler is usually installed on the root logger. The root logger is not subject to garbage collection.

jmehrens
  • 10,580
  • 1
  • 38
  • 47