Question
Pai G
IN
Last activity: 28 Feb 2018 23:07 EST
How to enable log rotation in Tomcat 8.5
Hi,
We need to enable log file rolling of tomcat logs. Does anyone point me how to do the same?
Thanks
Manju.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
AU
Do you mean the pegaRULES logs? If yes, provide the Pega version
Pai G
IN
No, its tomcat-stdout logs in Tomcat/logs folder
Pegasystems Inc.
US
Hi Manju,
You can have a look into this discussion answer regarding your query which might help you to proceed further. The referred discussion explained with the tomcat 6.0 logging documentation reference, as you are using tomcat 8.5 sharing the corresponding logging documentation over here.
Hope this might help you to proceed further.
Regards
Mahesh
Pegasystems Inc.
IN
The following steps describe configuring log4j to output Tomcat's internal logging.
The following steps describe configuring log4j to output Tomcat's internal logging.
- Create a file called log4j.properties with the following content and save it into $CATALINA_BASE/lib
- log4j.rootLogger = INFO, CATALINA
- # Define all the appenders
- log4j.appender.CATALINA = org.apache.log4j.DailyRollingFileAppender
- log4j.appender.CATALINA.File = ${catalina.base}/logs/catalina
- log4j.appender.CATALINA.Append = true
- log4j.appender.CATALINA.Encoding = UTF-8
- # Roll-over the log once per day
- log4j.appender.CATALINA.DatePattern = '.'yyyy-MM-dd'.log'
- log4j.appender.CATALINA.layout = org.apache.log4j.PatternLayout
- log4j.appender.CATALINA.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
- log4j.appender.LOCALHOST = org.apache.log4j.DailyRollingFileAppender
- log4j.appender.LOCALHOST.File = ${catalina.base}/logs/localhost
- log4j.appender.LOCALHOST.Append = true
- log4j.appender.LOCALHOST.Encoding = UTF-8
- log4j.appender.LOCALHOST.DatePattern = '.'yyyy-MM-dd'.log'
- log4j.appender.LOCALHOST.layout = org.apache.log4j.PatternLayout
- log4j.appender.LOCALHOST.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
- log4j.appender.MANAGER = org.apache.log4j.DailyRollingFileAppender
- log4j.appender.MANAGER.File = ${catalina.base}/logs/manager
- log4j.appender.MANAGER.Append = true
- log4j.appender.MANAGER.Encoding = UTF-8
- log4j.appender.MANAGER.DatePattern = '.'yyyy-MM-dd'.log'
- log4j.appender.MANAGER.layout = org.apache.log4j.PatternLayout
- log4j.appender.MANAGER.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
- log4j.appender.HOST-MANAGER = org.apache.log4j.DailyRollingFileAppender
- log4j.appender.HOST-MANAGER.File = ${catalina.base}/logs/host-manager
- log4j.appender.HOST-MANAGER.Append = true
- log4j.appender.HOST-MANAGER.Encoding = UTF-8
- log4j.appender.HOST-MANAGER.DatePattern = '.'yyyy-MM-dd'.log'
- log4j.appender.HOST-MANAGER.layout = org.apache.log4j.PatternLayout
- log4j.appender.HOST-MANAGER.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
- log4j.appender.CONSOLE = org.apache.log4j.ConsoleAppender
- log4j.appender.CONSOLE.Encoding = UTF-8
- log4j.appender.CONSOLE.layout = org.apache.log4j.PatternLayout
- log4j.appender.CONSOLE.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
- # Configure which loggers log to which appenders
- log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost] = INFO, LOCALHOST
- log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager] =\
- INFO, MANAGER
- log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager] =\
- INFO, HOST-MANAGER
With the help of DailyRollingFileAppender you can roll the logs daily .
For more information go through below article.
https://tomcat.apache.org/tomcat-7.0-doc/logging.html#Using_Log4j
Thanks,
Arun
Intel
IN
Hi Arun,
We tried implementing the changes, Tomcat is not starting even catalina file itself is not getting creating (attaching logs). Our Tomcat version is "8.5.23"
Even i tried following the steps in the link that you attached for the reference, still no luck !!
Please assist.
Thanks & Regards,
Narhar Dev Sharma