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 .Properties ;
@@ -302,9 +299,31 @@ private RequestLog createRequestLog() {
302299 log .setAppend (true );
303300 log .setLogTimeZone ("GMT" );
304301 log .setLogLatency (true );
302+ createRotateFile (logPath );
305303 return log ;
306304 }
307305
306+ private void createRotateFile (File logPath ) {
307+ String rotatefile = "/etc/logrotate/access" ;
308+ String fileContents = logPath .getAbsolutePath () + " {\n "
309+ + " copytruncate"
310+ + " daily"
311+ + " rotate 14"
312+ + " compress"
313+ + " missingok"
314+ + " create 0644 cloud cloud"
315+ + "}" ;
316+ File rotateConfigFile = new File (rotatefile );
317+ try {
318+ FileWriter fw = new FileWriter (rotateConfigFile );
319+ fw .write (fileContents );
320+ fw .close ();
321+ } catch (IOException e ) {
322+ // log but continue without rotate (for now)
323+ LOG .warn ("no way to rotate access log, continuing as is" );
324+ }
325+ }
326+
308327 private URL getResource (String aResource ) {
309328 return Thread .currentThread ().getContextClassLoader ().getResource (aResource );
310329 }
You can’t perform that action at this time.
0 commit comments