diff options
author | James Moger <james.moger@gitblit.com> | 2014-02-21 11:14:47 -0500 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-02-21 11:14:47 -0500 |
commit | aa61fc86db4f5ebf645ecf69c6f5ec36f2973e5a (patch) | |
tree | 219a5cb4ebc41f47926e26f5a407f24fafc3a450 /src/main/java/com | |
parent | dcbbad73966a91146b7aeae6fea444471f26f155 (diff) | |
download | gitblit-aa61fc86db4f5ebf645ecf69c6f5ec36f2973e5a.tar.gz gitblit-aa61fc86db4f5ebf645ecf69c6f5ec36f2973e5a.zip |
Add GO launch parameter to specify daily, rolling log file generation
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/gitblit/GitBlitServer.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/main/java/com/gitblit/GitBlitServer.java b/src/main/java/com/gitblit/GitBlitServer.java index 522fb579..1e51577a 100644 --- a/src/main/java/com/gitblit/GitBlitServer.java +++ b/src/main/java/com/gitblit/GitBlitServer.java @@ -20,6 +20,7 @@ import java.io.BufferedWriter; import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.InetAddress;
@@ -33,8 +34,10 @@ import java.text.MessageFormat; import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import java.util.Properties;
import java.util.Scanner;
+import org.apache.log4j.PropertyConfigurator;
import org.eclipse.jetty.ajp.Ajp13SocketConnector;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
@@ -179,6 +182,34 @@ public class GitBlitServer { settings = new FileSettings(params.settingsfile);
}
}
+
+ if (params.dailyLogFile) {
+ // Configure log4j for daily log file generation
+ InputStream is = null;
+ try {
+ is = getClass().getResourceAsStream("/log4j.properties");
+ Properties loggingProperties = new Properties();
+ loggingProperties.load(is);
+
+ loggingProperties.put("log4j.appender.R.File", new File(baseFolder, "logs/gitblit.log").getAbsolutePath());
+ loggingProperties.put("log4j.rootCategory", "INFO, R");
+
+ if (settings.getBoolean(Keys.web.debugMode, false)) {
+ loggingProperties.put("log4j.logger.com.gitblit", "DEBUG");
+ }
+
+ PropertyConfigurator.configure(loggingProperties);
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ is.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
logger = LoggerFactory.getLogger(GitBlitServer.class);
logger.info(Constants.BORDER);
logger.info(" _____ _ _ _ _ _ _");
@@ -614,6 +645,9 @@ public class GitBlitServer { @Parameter(names = { "--tempFolder" }, description = "Folder for server to extract built-in webapp")
public String temp = FILESETTINGS.getString(Keys.server.tempFolder, "temp");
+ @Parameter(names = { "--dailyLogFile" }, description = "Log to a rolling daily log file INSTEAD of stdout.")
+ public Boolean dailyLogFile = false;
+
/*
* GIT Servlet Parameters
*/
|