As I mentioned in the title, there is a problem about my slf4j tomcat logging configuration. The thing is, whereas I can rotate catalina.out to different files like daily appender, catalina.out file itself continues growing and I cannot figure out why.
Btw, I already use my application's log file in order to use slf4j logger.info debug and any other else features, however I still need catalina.out to see what is going on on the fly from the console. That's why I need to continue using catalina.out and myApplication.log simultaneously.
Here is my tomcat logging properties under tomcat_home/conf
handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
.handlers = 1catalina.org.apache.juli.FileHandler
1catalina.org.apache.juli.FileHandler.level = FINE
1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.
2localhost.org.apache.juli.FileHandler.level = FINE
2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.
3manager.org.apache.juli.FileHandler.level = FINE
3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.FileHandler.prefix = manager.
4host-manager.org.apache.juli.FileHandler.level = FINE
4host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
4host-manager.org.apache.juli.FileHandler.prefix = host-manager.
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.FileHandler
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.FileHandler
Tomcat's policy on this is as follows:
it should not be an issue because nothing should be printing to standard output since you are using a logging package
As for me I do not agree with them cause most of the time developers "DO" log stuff to console as one of the logging framework appenders/handlers for development time debug purposes (e.g. just to see logging output at the IDE console).
Here is the solution I use...
Setup your logging framework to NOT write anything into standard output on your dev/staging/prod environments. This will keep catalina.out very small with just basic info that is written with direct standard output writes (oppesed to log4j, logback, etc writes). Of cause if you have some direct standard output writes you will need to replace them with logger.
As I said above it is useful to write to standard output while developing in IDE (Eclipse, IDEA or whatever you use) to get those logs visible in developer's console.
Here is how you can tweak all that with logback configuration (but perfectly works with log4j and I believe other logging frameworks):
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${my.console.level}</level>
</filter>
<encoder>
<pattern>%d %-5p [%c{0}] %m%n</pattern>
</encoder>
</appender>
So I use
<level>${my.console.level}</level>
to specify logging level for the console appender.
Then just pass -Dmy.console.level=OFF for your jvm startup on your dedicated environment (dev, staging, prod) to disable writing to standard output. Use -Dmy.console.level=ALL in IDE.
Basically this is all. You can also use this approach to control your loggers log level.