WebObjects/Web 应用程序/部署/日志记录
外观
我不记得是谁给了我这个基本起点,但我认为可能是乔纳森之一。您需要更改文件名以使其在非 Unix 部署系统下工作。
您会发现先进入编辑模式更容易复制源代码。
public static void main(String argv[]) { try { String baseOutputPath = null; //look for a -WOOutputPath argument for (int i=0; i<argv.length; i++) { if ( argv[i].equals("-WOOutputPath") && !argv[i+1].equals("/dev/null") ) { String outputPath = argv[i+1]; baseOutputPath = outputPath; java.io.File outputFile = new java.io.File(outputPath); if (outputFile.exists()) { // move old file out of way to new location, //name based on existing name with an appended timestamp // Format the current time. java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd_HH:mm:ss"); java.util.GregorianCalendar now = new java.util.GregorianCalendar(); String dateSuffix = ".bck-" + formatter.format(now.getTime()); System.err.println("new name: " + outputPath + dateSuffix); java.io.File renamedFile = new java.io.File(outputPath + dateSuffix); outputFile.renameTo(renamedFile); } break; } } } catch (Throwable e) { //just so any Throwables generated in trying to do this don't //keep our app from launching. System.err.println("Ignoring: " + e); } WOApplication.main(argv, Application.class); }