imesh
imesh

Reputation: 123

How to reduce the server log size in jetty

I want to know how can I split the jetty server log when it reach to 10MB file size and backup while running?

I am using jetty 8 web server.

Thanks in advance.

Imesh

Upvotes: 0

Views: 2432

Answers (2)

imesh
imesh

Reputation: 123

Thanks Jesse for the reply but I did not try the way you mentioned. I resolved the problem in this way. Downloaded the jetty source and got the logging file named RolloverFileOutputStream.java then I changed the value maxFileLenth in the RollTaskBySize() method.

long maxFileLenth  = 1048576*10L;    //(10MB)

I put this file inside my source code and changed the value in jetty-loggin.xml. Set the path to pick up the modified RolloverFileOutputStream.java from my project as below in bold.

<Configure id="Server" class="org.eclipse.jetty.server.Server">
<New id="ServerLog" class="java.io.PrintStream">
  <Arg>
      <!-- ****** THIS IS THE CHANGE THAT I MADE ***** -->
      <New class="rezg.gdsws.util.RolloverFileOutputStream">
      <Arg>
<Property name="jetty.logs" default="/var/log/rezg/app/jetty"/>/yyyy_mm_dd.Server.log
      </Arg>
      <Arg type="boolean">false</Arg>
      <Arg type="int">90</Arg>
      <Arg><Call class="java.util.TimeZone" name="getTimeZone"><Arg>GMT</Arg></Call></Arg>
      <Get id="ServerLogName" name="datedFilename"/>
    </New>
  </Arg>
</New>

Upvotes: 1

jesse mcconnell
jesse mcconnell

Reputation: 7182

drop in an slf4j api jar into the lib directory and slf4j will be used for logging from that point on..put in the logging impl you want and configure accordingly

you can see the basic setup with logback doing the heavy lifting here:

http://wiki.eclipse.org/Jetty/Tutorial/Sifting_Logs_with_Logback

Upvotes: 1

Related Questions