File tree Expand file tree Collapse file tree 1 file changed +23
-4
lines changed
client/src/main/java/org/apache/cloudstack Expand file tree Collapse file tree 1 file changed +23
-4
lines changed Original file line number Diff line number Diff line change 1818//
1919package org .apache .cloudstack ;
2020
21- import java .io .File ;
22- import java .io .FileInputStream ;
23- import java .io .IOException ;
24- import java .io .InputStream ;
21+ import java .io .*;
2522import java .lang .management .ManagementFactory ;
2623import java .net .URL ;
2724import java .util .Arrays ;
@@ -333,9 +330,31 @@ private RequestLog createRequestLog() {
333330 log .setAppend (true );
334331 log .setLogTimeZone ("GMT" );
335332 log .setLogLatency (true );
333+ createRotateFile (logPath );
336334 return log ;
337335 }
338336
337+ private void createRotateFile (File logPath ) {
338+ String rotatefile = "/etc/logrotate/access" ;
339+ String fileContents = logPath .getAbsolutePath () + " {\n "
340+ + " copytruncate"
341+ + " daily"
342+ + " rotate 14"
343+ + " compress"
344+ + " missingok"
345+ + " create 0644 cloud cloud"
346+ + "}" ;
347+ File rotateConfigFile = new File (rotatefile );
348+ try {
349+ FileWriter fw = new FileWriter (rotateConfigFile );
350+ fw .write (fileContents );
351+ fw .close ();
352+ } catch (IOException e ) {
353+ // log but continue without rotate (for now)
354+ LOG .warn ("no way to rotate access log, continuing as is" );
355+ }
356+ }
357+
339358 private URL getResource (String aResource ) {
340359 return Thread .currentThread ().getContextClassLoader ().getResource (aResource );
341360 }
You can’t perform that action at this time.
0 commit comments