[jetty-dev] Support log compression with default NCSARequestLog?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jetty-dev] Support log compression with default NCSARequestLog?

Matthew Sheppard-2

I'd be interested in having support in NCSARequestLog for compressing log files to save space. Would you be open to adding that as a feature?

(Aside: I appreciate I could already achieve this by switching to slf4j, but that's mildly inconvenient for reasons that probably aren't of interest)

At a glance, it seems like actually doing it ought to be fairly simple, e.g.

msheppard@MacBook-Pro ~/D/t/jetty.project> git diff
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/RolloverFileOutputStream.java b/jetty-util/src/main/java/org/eclipse/jetty/util/RolloverFileOutputStream.java
index db3b7be..7659ef1 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/RolloverFileOutputStream.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/RolloverFileOutputStream.java
@@ -32,6 +32,7 @@ import java.util.Locale;
 import java.util.TimeZone;
 import java.util.Timer;
 import java.util.TimerTask;
+import java.util.zip.GZIPOutputStream;

 /**
  * RolloverFileOutputStream.
@@ -272,7 +273,11 @@ public class RolloverFileOutputStream extends FilterOutputStream
             if (!_append && file.exists())
                 file.renameTo(new File(file.toString()+"."+_fileBackupFormat.format(now)));
             OutputStream oldOut=out;
-            out=new FileOutputStream(file.toString(),_append);
+            OutputStream newOut=new FileOutputStream(file.toString(),_append);
+            if (filename.endsWith(".gz"))
+                newOut=new GZIPOutputStream(newOut);
+            out=newOut;
             if (oldOut!=null)
                 oldOut.close();
             //if(log.isDebugEnabled())log.debug("Opened "+_file);

If it would be of interest but not a priority for any current developers I might be able to dedicate a little time to properly implementing it if someone can provide some guidance about how you would prefer to see it exposed configuration-wise.


(Posted this as https://github.com/eclipse/jetty.project/issues/1458 but reposting it here in case that’s the right way to submit such things)


Cheers,

Matt


_______________________________________________
jetty-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-dev