'Tomcat catalina logging

I am using SpringMVC framework and Java 8 for development. In the Tomcat catalina.out file, the date timestamp and threadid are not added along with my application logs.

I am getting the logs as below

INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-9090"]
INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["https-jsse-nio-8443"]
INFO [main] org.apache.catalina.core.StandardService.stopInternal Stopping service [Catalina]
java.io.FileNotFoundException: /apps/opt/sws/logs
Request SecurityContextHolderAwareRequestWrapper
Beginning of the api method

I need to have the date timestamp and threadid be added along with my application example:-

2022-01-08 12:51:23:986[Thread - http-nio-exec-4id] INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-9090"]
2022-01-08 12:52:56:986[Thread - http-nio-exec-8id] INFO Request SecurityContextHolderAwareRequestWrapper
2022-01-08 12:58:45:986[Thread - http-nio-exec-9id] INFO Beginning of the api method
2022-01-08 12:58:55:986[Thread - http-nio-exec-47id] ERROR Exception happened while loading

Please help me, where I need to change the settings and provide any samples.



Solution 1:[1]

You could do the followings to achieve this. Add the following line to log4j.properties.

java.util.logging.SimpleFormatter.format=%1$tF %1$tT [%4$-7s] %5$s %n

else you can also change Tomcat logging to log4j. You may refer here.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Du-Lacoste