# HG changeset patch # User Andrea Gualano # Date 1333095649 -7200 # Branch release71_fixes # Node ID 983067cbcb9f9e05932b7f96bf895b5499a8ddc4 # Parent a903faa1d680d27d8d991defd10971504d0e8e48 issue #209786: Allow configuring the number of log files in the var/log directory diff -r a903faa1d680 -r 983067cbcb9f core.startup/arch.xml --- a/core.startup/arch.xml Thu Mar 01 21:52:54 2012 +0100 +++ b/core.startup/arch.xml Fri Mar 30 10:20:49 2012 +0200 @@ -602,6 +602,12 @@ Allows unit tests to prevent changes to System.err and System.out by the logging infrastructure. + + Changes the number of files used for log rotation. If started with + -J-DTopLogging.numberOfLogFiles=number then the log files for + number-1 previous executions will be preserved. Default and + minimum number is 3. + Disables #113341 so that the first version of a module JAR to be encountered is loaded, even if a later cluster contains a newer version of the same module. diff -r a903faa1d680 -r 983067cbcb9f core.startup/src/org/netbeans/core/startup/TopLogging.java --- a/core.startup/src/org/netbeans/core/startup/TopLogging.java Thu Mar 01 21:52:54 2012 +0100 +++ b/core.startup/src/org/netbeans/core/startup/TopLogging.java Fri Mar 30 10:20:49 2012 +0200 @@ -406,21 +406,27 @@ try { File dir = new File(new File(home, "var"), "log"); dir.mkdirs (); - File f = new File(dir, "messages.log"); - File f1 = new File(dir, "messages.log.1"); - File f2 = new File(dir, "messages.log.2"); - if (f2.exists()) { - f2.delete(); + int n = Integer.getInteger("TopLogging.numberOfLogFiles", 3); // NOI18N + if (n < 3) { + n = 3; } - if (f1.exists()) { - f1.renameTo(f2); - } - if (f.exists()) { - f.renameTo(f1); + File[] f = new File[n]; + f[0] = new File(dir, "messages.log"); + for (int i = 1; i < n; i++) { + f[i] = new File(dir, "messages.log." + i); } - FileOutputStream fout = new FileOutputStream(f, false); + if (f[n - 1].exists()) { + f[n - 1].delete(); + } + for (int i = n - 2; i >= 0; i--) { + if (f[i].exists()) { + f[i].renameTo(f[i + 1]); + } + } + + FileOutputStream fout = new FileOutputStream(f[0], false); Handler h = new StreamHandler(fout, NbFormatter.FORMATTER); h.setLevel(Level.ALL); h.setFormatter(NbFormatter.FORMATTER);