mirror of https://github.com/apache/cloudstack.git
Merge ff27a44290 into b7d4df0a11
This commit is contained in:
commit
9bf2f428df
|
|
@ -20,8 +20,9 @@ package org.apache.cloudstack;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.FileWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.net.URL;
|
||||
import java.util.Properties;
|
||||
|
|
@ -309,9 +310,31 @@ public class ServerDaemon implements Daemon {
|
|||
log.setAppend(true);
|
||||
log.setLogTimeZone("GMT");
|
||||
log.setLogLatency(true);
|
||||
createRotateFile(logPath);
|
||||
return log;
|
||||
}
|
||||
|
||||
private void createRotateFile(File logPath) {
|
||||
String rotatefile = "/etc/logrotate.d/access";
|
||||
String fileContents = logPath.getAbsolutePath() + " {\n"
|
||||
+ " copytruncate"
|
||||
+ " daily"
|
||||
+ " rotate 14"
|
||||
+ " compress"
|
||||
+ " missingok"
|
||||
+ " create 0644 cloud cloud"
|
||||
+ "}";
|
||||
File rotateConfigFile = new File(rotatefile);
|
||||
try {
|
||||
FileWriter fw = new FileWriter(rotateConfigFile);
|
||||
fw.write(fileContents);
|
||||
fw.close();
|
||||
} catch (IOException e) {
|
||||
// log but continue without rotate (for now)
|
||||
LOG.warn("no way to rotate access log, continuing as is");
|
||||
}
|
||||
}
|
||||
|
||||
private URL getResource(String aResource) {
|
||||
return Thread.currentThread().getContextClassLoader().getResource(aResource);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue