Changes for page Log Rotation

Last modified by David Avendasora on 2010/11/30 06:46

From version 1.1
edited by smmccraw
on 2007/07/08 09:45
Change comment: There is no comment for this version
To version 3.1
edited by Pascal Robert
on 2007/09/03 21:48
Change comment: There is no comment for this version

Summary

Details

Page properties
Title
... ... @@ -1,1 +1,1 @@
1 -Programming__WebObjects-Web Applications-Deployment-Logging
1 +Web Applications-Deployment-Logging
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.smmccraw
1 +XWiki.probert
Content
... ... @@ -1,51 +1,49 @@
1 -== Log Rotation ==
1 +== Log Rotation ==
2 2  
3 -=== Mike Kienenberger ===
3 +=== Mike Kienenberger ===
4 4  
5 5  I can't remember who gave me the basic starting point for this, but I think it may have been one of the Jonathans. You'll need to change the filenames to make it work under non-unix deployment systems.
6 6  
7 7  You'll find it easier to copy out the source by going into Edit mode first.
8 8  
9 -{{panel}}
9 +{{code}}
10 10  
11 - public static void main(String argv[])
12 - {
13 - try
14 - {
15 - String baseOutputPath = null;
16 -
17 - //look for a -WOOutputPath argument
18 - for (int i=0; i<argv.length; i++) {
19 - if ( argv[i].equals("-WOOutputPath") &&
20 - !argv[i+1].equals("/dev/null") ) {
21 - String outputPath = argv[i+1];
22 - baseOutputPath = outputPath;
23 - java.io.File outputFile = new java.io.File(outputPath);
24 - if (outputFile.exists()) {
25 - // move old file out of way to new location,
26 - //name based on existing name with an appended timestamp
27 -
28 - // Format the current time.
29 - java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
30 - java.util.GregorianCalendar now = new java.util.GregorianCalendar();
31 - String dateSuffix = ".bck-" + formatter.format(now.getTime());
32 - System.err.println("new name: " + outputPath + dateSuffix);
33 - java.io.File renamedFile = new java.io.File(outputPath + dateSuffix);
34 - outputFile.renameTo(renamedFile);
35 - }
36 - break;
37 - }
38 - }
39 - }
40 - catch (Throwable e) {
41 - //just so any Throwables generated in trying to do this don't
42 - //keep our app from launching.
43 - System.err.println("Ignoring: " + e);
44 - }
45 -
46 - WOApplication.main(argv, Application.class);
47 - }
11 + public static void main(String argv[])
12 + {
13 + try
14 + {
15 + String baseOutputPath = null;
48 48  
49 -{{/panel}}
17 + //look for a -WOOutputPath argument
18 + for (int i=0; i<argv.length; i++) {
19 + if ( argv[i].equals("-WOOutputPath") &&
20 + !argv[i+1].equals("/dev/null") ) {
21 + String outputPath = argv[i+1];
22 + baseOutputPath = outputPath;
23 + java.io.File outputFile = new java.io.File(outputPath);
24 + if (outputFile.exists()) {
25 + // move old file out of way to new location,
26 + //name based on existing name with an appended timestamp
50 50  
51 -Category:WebObjects
28 + // Format the current time.
29 + java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
30 + java.util.GregorianCalendar now = new java.util.GregorianCalendar();
31 + String dateSuffix = ".bck-" + formatter.format(now.getTime());
32 + System.err.println("new name: " + outputPath + dateSuffix);
33 + java.io.File renamedFile = new java.io.File(outputPath + dateSuffix);
34 + outputFile.renameTo(renamedFile);
35 + }
36 + break;
37 + }
38 + }
39 + }
40 + catch (Throwable e) {
41 + //just so any Throwables generated in trying to do this don't
42 + //keep our app from launching.
43 + System.err.println("Ignoring: " + e);
44 + }
45 +
46 + WOApplication.main(argv, Application.class);
47 + }
48 +
49 +{{/code}}