0

We are using log4j2 to handle our application logs, and the application is running under JBoss EAP 7.1.

In my log4j2.xml file, I am trying to keep a maximum of 5 log files of 10MB each, but there is something strange going on because I am ending up with 5 or more log files per day (depending on the appender). I don't know how/why the date is being added to my file names for most of my logs nor why I have more than 5 logs (per day) in some instances.

Here is part of my log4j2.xml:

<RollingFile name="springAppender" fileName="/opt/jboss-eap-7.1/standalone/log/spring.log"
             filePattern="/opt/jboss-eap-7.1/standalone/log/spring-%i.log">
  <PatternLayout> <pattern>%d${ISO8601} [%t] [%X{sessionId}] [%X{orgName}] %-9p %c - %enc{%m}%n</pattern></PatternLayout>
  <Policies>
    <SizeBasedTriggeringPolicy size="10 MB"/>
  </Policies>
      <DefaultRolloverStrategy max="5"/>
</RollingFile>
<RollingFile name="SqlAppender" fileName="/opt/jboss-eap-7.1/standalone/log/sql.log"
             filePattern="/opt/jboss-eap-7.1/standalone/log/sql-%i.log">
  <PatternLayout> <pattern>%d{ISO8601} [%t] [%X{sessionId}] [%X{orgName}] %-9p %c - %enc{%m}%n</pattern></PatternLayout>
  <Policies>
    <SizeBasedTriggeringPolicy size="10 MB"/>
  </Policies>
      <DefaultRolloverStrategy max="5"/>
</RollingFile>

And here is an excerpt of my log directory listing:

-rw-r--r--. 1 jboss jboss 10485857 May 30 05:26 spring-05-30-2019-1.log

-rw-r--r--. 1 jboss jboss 10485924 May 30 05:34 spring-05-30-2019-2.log

-rw-r--r--. 1 jboss jboss 10485861 May 30 05:40 spring-05-30-2019-3.log

-rw-r--r--. 1 jboss jboss 10485796 May 30 05:49 spring-05-30-2019-4.log

-rw-r--r--. 1 jboss jboss 10485946 May 30 05:56 spring-05-30-2019-5.log

-rw-r--r--. 1 jboss jboss 10485950 May 30 07:43 spring-05-30-2019-6.log

-rw-r--r--. 1 jboss jboss 10485808 May 30 13:13 spring-05-30-2019-7.log

-rw-r--r--. 1 jboss jboss 2302827 Jun 25 17:51 spring.log

-rw-r--r--. 1 jboss jboss 10485766 Jun 25 04:51 sql-1.log

-rw-r--r--. 1 jboss jboss 10485896 Jun 25 04:52 sql-2.log

-rw-r--r--. 1 jboss jboss 10485990 Jun 25 04:54 sql-3.log

-rw-r--r--. 1 jboss jboss 10485874 Jun 25 04:56 sql-4.log

-rw-r--r--. 1 jboss jboss 10485967 Jun 25 04:58 sql-5.log

-rw-r--r--. 1 jboss jboss 5782246 Jun 25 14:55 sql.log

As far as I can see, the SqlAppender and the springAppender are structurally the same. Yet my sql.log rolls as desired, while spring.log both includes the date in the rolled file name as well as preserves more than the max 5 files. This is slowly filling my hard drive.

I have grepped within my JBoss directory looking for patterns like "\-yyyy\-" that might tip me off to another place that might be controlling how logs roll to no avail.

We run in standalone mode, and there is a periodic-rotating-file-handler in our standalone.xml, but that controls server.log. There is also a logging.properties file that I believe controls logging until the application fully starts and hands off the logging to log4j2, but I don't see anything in there that seems to contain a pattern that would insert a date into my file names.

How do I stop this behavior?

pjd
  • 1,163
  • 8
  • 17
  • The fist thing I would do is change the pattern of the PatternLayout to see if the resulting logs are truly generated by log4j. – D.B. Jun 26 '19 at 14:42
  • Changing the pattern also tells you if the config file you think you're using is really the one being used by log4j2. – D.B. Jun 30 '19 at 14:46
  • This [answer](https://stackoverflow.com/a/24566672/12224743) might help your query. I hope – Umeshwaran Oct 16 '19 at 07:47
  • @D.B. The logs seem to be generated by log4j but something else is controlling the rolling. – pjd Oct 22 '19 at 19:27
  • @Umeshwaran, unfortunately that answer did not address the problem I am experiencing. – pjd Oct 22 '19 at 19:27

0 Answers0