king
I'm new here

logrotate and FirstSpirit

Dear e-Spirit community,

when for Tomcat and Apache instances within the FirstSpirit editing environmnt the famous log rotation framework "logrorate" has already been setup and configured, there might be a reasonable interest to introduce "logrotate" for the FirstSpirit server, too.

At first, the "log4j" logrotation has to be disabled - whether a standard or custom log4j appender is used. To our understanding, this could be done via:

  • switching from a "FSAppender" to just a standard log4j "FileAppender" within the "conf/fs-logging.properties" configuration file. This will help the FirstSpirit server to still use "log4j" for writing to FirstSpirit-specific logs using different log levels but without any log4j specific log rotation. The problem here: a FileAppender needs a specified log file where the log output is written to. FirstSpirit currently uses three individual system log files "fs-server.log", "fs-clients.log", "fs-database.log" that will then be reduced to just one single file.
  • increasing the "maxFileSize" attribute of the FirstSpirit specific "de.espirit.firstspirit.server.logging.FSAppender" to a big value where "logrotate" will come before the rotation of the "FSAppender". In my humble opinion, this seems to be the only option as the FSAppender log rotation feature cannot be deactivated currently!
    -> there is a bug available in FS 4.2 R4 preventing setting custom "maxFileSize" values for "FSAppender", see https://helpdesk.e-spirit.com/requests/10956 being fixed with 5.0 R4

It's clear that "log4j" cannot be replaced completely, as the application references it within their Java classes. The above change will take effect on the following log files in "<fs_install_path>/log":

- "fs-server.log"

- "fs-clients.log"

- "fs-database.log"

- additional individually configured log file outputs configured in "fs-logging.properties"

except for the log files created in the "<fs_install_path>/log"-sub-folder named "schedule". Reason: these log files are not rotated as they are created per scheduler entry individually using individual files.

When in future log rotation for the above log files has to be guaranteed via  "logrotate", a configuration file for "logrotate" is essential. See an example configuration file for FirstSpirit enclosed:

# continue and throw no error message when log file is not present

missingok

# truncate the original log file in place after creating a copy

copytruncate

# compress the file

compress

/opt/wcms/fs4/log/fs-server.log /opt/wcms/fs4/log/fs-clients.log /opt/wcms/fs4/log/fs-database.log {

     # rotate hourly

     hourly

     # keep 96 hours (= 4 days) of backlogs, see hourly

     rotate 96

     # "dateext" directive has to be deactivated as search within FirstSpirit server

     # monitoring would not work for FirstSpirit log files otherwise, see

     # "FirstSpirit Manual for Administrators"

     #dateext

     # size that triggers log-rotation, here: 1024

     size 1024M

}

/opt/wcms/fs4/log/fs-wrapper.log /opt/wcms/fs4/log/fs-gc.log {

     # rotate daily

     daily

     # keep 4 days of backlogs, see daily

     rotate 4

     # "dateext" directive has to be deactivated as search within FirstSpirit server

     # monitoring would not work for FirstSpirit log files otherwise, see

     # "FirstSpirit Manual for Administrators"

     dateext

}

Important: to ensure allowing searching FirstSpirit log files in FirstSpirit Web-Monitor, "log4j.appender.fs.datedLogging" has to be enabled for FirstSpirit's custom log4j-FSAppender (see "FirstSpirit Manual for Administrators", chapter "Logging configuration"). That's why logrotate's "dateext" directive has to be disabled for FirstSpirit specific log files.

Nevertheless, it might be much better to allow a complete deactivation of "logrotation" within the custom log4j FirstSpirit "FSAppender". Up to now, this is not possible Smiley Sad

Our questions:

  • do you agree so far?
  • is there - maybe an undocumented - possibility to deactivate the log rotation feature in FirstSpirit's custom log4j-FSAppender?
  • will an additional FSAppender propererty be introduced to allow deactivating log rotation?
  • are there better suggestions?
1 Reply
king
I'm new here

Re: logrotate and FirstSpirit

To allow to configure a timestamp based target log file name in "logrotate" natively a feature request has been raised @RedHat below:

https://bugzilla.redhat.com/show_bug.cgi?id=1113582