I need to display the date and time of actual log info within the catalina.out log file for my tomcat7 installation. From the web I found the solution of adding this line to the logging.properties file, but it does not work. I added the following:
1catalina.java.util.logging.SimpleFormatter.format=[%1$td.%1$tm.%1$tY %1$tH:%1$tM:%1$tS,%1$tL
Right now its just a bunch of data that has zero timestamps. I just want the standard yyyymmdd hhmmss
that precedes the INFO or ERROR, etc in the log output.
what is present right now in my logging.properties file is this (I added the last line obviously):
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
1catalina.java.util.logging.SimpleFormatter.format=[%1$td.%1$tm.%1$tY %1$tH:%1$tM:%1$tS,%1$tL
the version Im using is apache-tomcat-7.0.82.
Any help you can provide would be great, and thank you in advance.
By default, the Tomcat HTTP Access Logs are stored in the dotserver/tomcat-X.x/logs/ folder within the dotCMS distribution, and the files are named dotcms_access. YYYY-MM-DD. log, where the YYYY-MM-DD in the file name is replaced by the date of the log file.
By default, the catalina. out file is located in the logs directory under Tomcat's root directory. For example, /opt/netiq/idm/apps/tomcat/logs/catalina.
Catalina. out simply contains everything that is written to Tomcat's "System. out" and "System. err". The name "catalina.
The main Apache Tomcat configuration file is at installdir/apache-tomcat/conf/server. xml. Once Apache Tomcat starts, it will create several log files in the installdir/apache-tomcat/logs directory. The main log file is the catalina.
This is what worked for me on Tomcat 7.0.99:
...
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.ConsoleHandler.encoding = UTF-8
# My special format:
java.util.logging.SimpleFormatter.format=%1$tF %1$tT [%4$-7s] %5$s %n
...
The first three lines are out of the box default settings. Just the last line defines SimpleFormatter. Logfile looks like this:
2020-02-03 11:55:26 [INFORMATION] Loaded APR based Apache Tomcat Native library [1.2.23] using APR version [1.7.0].
2020-02-03 11:55:26 [INFORMATION] APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2020-02-03 11:55:26 [INFORMATION] OpenSSL successfully initialized [OpenSSL 1.1.1c 28 May 2019]
2020-02-03 11:55:26 [INFORMATION] Initialisiere ProtocolHandler["http-apr-8080"]
2020-02-03 11:55:26 [INFORMATION] Initialisiere ProtocolHandler["ajp-apr-8009"]
2020-02-03 11:55:26 [INFORMATION] Initialization processed in 368 ms
2020-02-03 11:55:26 [INFORMATION] Starting service [Catalina]
2020-02-03 11:55:26 [INFORMATION] Starting Servlet Engine: Apache Tomcat/7.0.99
For more information regarding SimpleFormatter see: Oracle Java Documentation - SimpleFormatter and for Formatter see: Oracle Java Documentation - Formatter.
You can even change Tomcat logging to log4j (see: Tomcat - Using_Log4j) but that needs some more effort and would be an overkill for my simple use case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With