javaspringspring-bootloggingembedded-tomcat-8

SpringBoot 2.1.3 : Embedded Tomcat Logging


I have developed a SpringBoot 2.1.3 WebApp with Thymeleaf 3. For quick testing purpose I create a fat jar with two SQL Procedure which automatically create the DB if it is not present and fill typological table if they are empty.

Now I put my .jar in a CentOS server and launch it by the command:

java -jar mywebapp.jar

All works perfectly but I find a bug in a form submit and I would like to examine the server (embedded) logs.

Which logging level I have to use in the below configuration inside the application.properties:

logging.level.org.apache.tomcat=?
logging.level.org.apache.catalina=?

And where I can find the log text file inside a Unix machine?

Thank you


Solution

  • First of all with embedded tomcat you have to enable log by adding to you application.properties

    server.tomcat.accesslog.enabled=true
    

    to specify base directory if you want to save log other then temp folder , also folder that will contain logs

    server.tomcat.basedir=tomcat
    server.tomcat.accesslog.directory=logs
    

    you can also specify suffix and prefix for logs file

    server.tomcat.accesslog.suffix=.log
    server.tomcat.accesslog.prefix=access_log
    

    for more properties see here list of common properties , search for tomcat and logging

    Also adding logging level as mentioned by the PO in the comment add

    logging.level.org.apache.tomcat=ALL