5

Is it possible to configure compressed logs in WildFly 10? Was not able to find the proper configuration here: https://docs.jboss.org/author/display/WFLY10/Handlers

TT.
  • 15,774
  • 6
  • 47
  • 88
Michael
  • 10,063
  • 18
  • 65
  • 104

2 Answers2

7

Log handlers are not supposed to zip log files. I assume, that you want to use log rotation and then zip older log entries. First, define a rotated file handler - you can decide to rotate either based on time e.g. every midnight or based on size e.g. every 5MB. An example of time based, daily rolling file handler:

<periodic-rotating-file-handler name="FILE" autoflush="true">
   <formatter>
       <pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
   </formatter>
   <file relative-to="jboss.server.log.dir" path="server.log"/>
   <suffix value=".yyyy-MM-dd"/>
   <append value="true"/>
</periodic-rotating-file-handler>

Now for the second part, compression. If you are on linux, the easiest way ho to do that is to setup a CRON job that would find all entries that you want to zip and compress them. For example you can setup your cron job to run this script:

ls server.log.*|grep -v '\.zip$' |xargs -i zip -m {}.zip {} 
yntelectual
  • 3,028
  • 18
  • 24
  • 2
    Ye, I already use periodic-rotating-file-handler. Very bad compression is not supported in WildFly. I do not like to use Cron for this – Michael Jun 19 '17 at 10:30
  • well, wildfly is an app server. Managing logfiles, their processing and so on is really not its goal. Any real-world app in production will require a well configured log processing pipeline anyhow. e.g. compress, backup, process with logstash, archive, delete... If you do not like cron, you can automate your log processing with some other tool, or write your own simple pipeline in python or java or whatever you fancy :) – yntelectual Jun 19 '17 at 11:00
  • 1
    At some point, hopefully WildFly 11, it will be supported by adding a `.zip` or `.gz` extension to the suffix for a rotated file. See https://issues.jboss.org/browse/LOGMGR-30 for details. – James R. Perkins Jun 19 '17 at 16:50
1

As per Wildfly 19, if you add .zip or .gz in the suffix, it'll automatically zip them when rotated.