Log4j2 and logback are preferable but if you want log4j-v1:
Log4j-v1-extras has it: (org.apache.log4j.rolling.RollingFileAppender)
<appender name="roll-by-time-and-size" class="org.apache.log4j.rolling.RollingFileAppender">
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
<param name="ActiveFileName" value="log4j/roll-by-time-and-size/app.log" />
<param name="FileNamePattern" value="log4j/roll-by-time-and-size/app.%d{HH-mm}.%i.log.gz" />
</rollingPolicy>
<triggeringPolicy
class="org.apache.log4j.rolling.SizeBasedTriggeringPolicy">
<param name="MaxFileSize" value="100" />
</triggeringPolicy>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p - %m%n" />
</layout>
</appender>
Source: https://www.baeldung.com/java-logging-rolling-file-appenders#5-rolling-based-on-size-and-time
Note: There is no old-file-deletion after X days. A cron job could be used to do that. If you don't want a cron job but want deletion, I'd recommend going with the log4j-v1 basic size-based RollingFileAppender or log4j-extras SizeBasedTriggeringPolicy (see baeldung article example).
Note: The "%i" in FileNamePattern is required for time + size to both work. It adds a large long-int (ticks?) to all backed-up log filenames. This is different from logback for which "%i" becomes 0,1,2,..
Log4j-extras dependency:
<dependency>
<groupId>log4j</groupId>
<artifactId>apache-log4j-extras</artifactId>
<version>1.2.17</version>
</dependency>