Goal: To record how I created an eclipse worksapce and project which
would run under both tomcat and GAE (Google App Engine) servers *

Package features:

The asterix is to admit that 100% compatibility was not possible.
1) GAE uses it's own datanucleus database structure which is not supported by tomcat. My solution was to comment this code out, which does have the downside of preventing use of the GAE datanucleus features.
2) It seems the ability to log to files is limited to tomcat. GAE can be made to log to the console, but debug logging local files seems to be not compatible with the cloud architecture. The console is ok for short blurbs, but really slows down after 1000 lines. Thus the console works for DWR enabled javascript debugging, but heavy logging output will suggest development under tomcat.

This package is for my own personal use only. Any other use by any other party is at their own risk. Any use of the contents of this page constitutes acceptance that such use is at their owwn use and that no other warrents or claims are made as to the contents.

Downloaded all the packages in the table below:
The versions listed are the most recent stable released versions of the products. I like 7Zip.exe for unpacking the zipped packages: it leaves the original zipped version, and makes a copy.   If the links provided should fail, remember always that     "Google is your friend".

Full Set of building blocks if you want to build your own
Name Location What it is suggested flavor clue
Java oracle.com programming language Java SE (Standard Edition) JDK (Java Development Kit) ver 7 ) Java SE... Downloads... JDK Download... version for your OS & bit Length
Tomcat tomcat.apache.org html server most recent release version downloads... Tomcat 7... Binary Distributions... core...verserion for your OS & bit Length
Eclipse eclipse.org IDE (Integrated Development Environment) Eclipse IDE for Java EE Developers yellow rectangle toward upper right, big bold Download Eclipse
log4J tomcat Log4J debugging logger latest release version version 1.2.17 tar.gz or .zip
JSTL JSTL.java.net allows use of "<c:out" in .jsp files javax.servlet.jsp.jstl-api-1.2.1.jar http://jstl.java.net/... download JSTL... JSTL API... javax.servlet.jsp.jstl-api-1.2.1.jar
DWR directwebremoting.org Direct Web Remoting - Easy Ajax for JAVA Version 3.0 DWR home page... downloat dwr... Ver 3.0... dwr.jar

Java:

My procedure is to go in and remove all currently installed versions of java first.   I and several of my friends have gotten into disfunction from having multiple copies of multiple versions of java on our computers. Eclipse points to a java environment, and by un-installing all the versions you no longer need you will avoid pointing to one of the downlevel javas. On my windows systems uninstalling a program is
       control panel...
          programs and features...
            click on publisher...
             look under two publishers (IBM, and more likely oracle) for anything JAVA
                click on the icon to the left of the java program name
                  wait for it to finish uninstalling
                    look to see if there are any other java's installed, if there are... click on the next one

Tomcat:

7-Zip extract file to any convenient location. I chose c:\program files which resulted in 7Zip creating c:\program files\apache-tomcat-7.0.35

Homespace:

7-Zip extract file to any convenient location. I chose c:\ which resulted in 7-Zip creating c:\homespace

eclipse:

7-Zip extract file to any convenient location. I chose c:\ which resulted in 7-Zip creating c:\eclipse

After eclipse is unzipped you'll want to execute the eclipse.exe. With this first execution, it will prompt you to select a workspace. You should enter     c:\homespace     and you probably want to click the "use this as the default" checkbox.
IMAGE FAIL: location 2B  c:\homespace and DO YES check the checkbox

Getting GAE (Google App Engine) running under eclipse


These instructions are based on the Google App Engine The google instructions do not include the way to allow tomcat server. When you want to deploy your project to the web, you will want to go into the google app engine documentation to learn how to regester your project and upload it.
        Help...
          Install New Software...
IMAGE FAIL:

in the work with text box type     https://dl.google.com/eclipse/plugin/4.2       and hit enter.
The block in the middle will show pending for some seconds, but will soon pop up with
IMAGE FAIL:

I selected a minimal set, and hit next
IMAGE FAIL:

It wants to verify the install details. Hit next.
IMAGE FAIL:

You'll need to accept the licence agreements. Hit finish.
IMAGE FAIL:

it will take a long time, on the order of a half hour or so, but don't wander off because. about 20 min in, it comes up with this which needs to have it's ok button clicked
IMAGE FAIL:

Seems like only a min later it wants permission to restart eclipse. Click the yes button
IMAGE FAIL:

when eclipse starts back up again, you'll have the GDT (Google Development Tools) icon in the eclipse icon bar
click on it
IMAGE FAIL:

click on New Web Application Project
IMAGE FAIL:


Fill in the Project Name
fill in the Package Name (it insists the package start with a lower case letter)
unclick the Use Google Web Toolkit
hit finish
IMAGE FAIL:


in the Project Explorer, RIGHT mouse button click on your new project
click on "Properties"
IMAGE FAIL:


On the left hand side, click on "Project Facets"
IMAGE FAIL:


next to the java checkbox. go over to where it says 1.7 and select 1.6 instead... GAE does not yet allow depoly of java 7 code.
Click on "Dynamic Web Module"
look down towards the bottom, click on the blue link "Further configuration available"
IMAGE FAIL:


change the content directory from WebContent to war
you do not need it to generate the web.xml, as GDT has allready done it
click OK
IMAGE FAIL:



You now have the GAE in place, and have prepped your project to allow Tomcat.

Running hello world on your local GAE server


in Project Explorer
click on the expander box next to the name of your project
click on war
Right mouse button click on war
New
file
in the file name entry field   hello.html
click on Finish
copy the text below into the hello.html tab which just opened

<html>
 <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>Hello Title</title>
  </head>
<body>
Hello World!
</body>
</html>


hit ctrl-S to save the text
in the Project Explorer click on your project to highlight it
right mouse button click
go down to Debug AS
move over to the side pulldown and click on "Web Application"
IMAGE FAIL:

The console will get a lot of red text. This is normal. Do not Panic
Eclipse showing red in the console does not even mean that any errors are occuring. After a few seconds the last line shoudl be...
INFO: The admin console is running at http://localhost:8888/_ah/admin
right mouse button click on localhost:8888/hello.html and select open in new tab.
A tab should appear with Hello Title this is running the hello.html on your local GAE server.

to stop your GAE local server

click on the red square in the console tab

Getting a tomcat server running under eclipse

Down in the lower right corner of the eclipse app... click on the "new server wizard" link in
IMAGE FAIL: shold be toward the lower right

and you will get the New Server dialog with one of two outcomes: Success is if your tomct directroy is identical to the tomcat directory on the computer which created the homespace. Success looks like
IMAGE FAIL: server name box has somthing in the entry field

Faiure is when your tomcat directory is different from the tomcat directory on the computer which created the homespace. Failure looks like:
IMAGE FAIL: server name box has nothing in it and is grey

If you have success skip ahead to Add Package To Server
If instead, you have failure you need to close the New Server dialog and go to the eclipse main menu bar.
       Window...
          Preferences...
            Server...
              Runtime Environment
The Server Runtime Environment dialog will show the link to the tomcat directory on the computer which created the homespace.
IMAGE FAIL:

You need to highlight it.
IMAGE FAIL:

and click remove.
IMAGE FAIL:

then click Add which opens the New Server Runtime Environment dialog (with the wrong choices)
IMAGE FAIL:

click on Apache Tomcat v7.0 and click the "Create new local server"
click FINISH to open a different dialog, which is also (somewhat irksomely) named New Server Runtime Environment
IMAGE FAIL:

clink on the the Browse button and in the resulting "Browse for Folder" dialog and navigate to your tomcat directory. Highlight it and click ok
IMAGE FAIL:

click on the installed JRE's button to open one of the many different eclipse "Preferences" dialogs.
Use the ADD button if necessary (this will not be necessary if you followed my suggestion to purge other Java JRE's and Java SDK's prior to the install of the current version SDK).
It is vital, that you have the checkbox next to the JDK clicked.
Click OK
IMAGE FAIL:

click the pulldown just to the left of the Installed JRE's button, and select the jdk
IMAGE FAIL:

Adding WegGLTutorials to the packages served:
Go to the servers tab (probably in the lower right corner) and RIGHT mouse button click on the Tomcat v7.0 ... The dark blue highlighted line
IMAGE FAIL:

click on "add and remove""
IMAGE FAIL:

click on WebGLTurorials
IMAGE FAIL:

click add
IMAGE FAIL:

click Finished
IMAGE FAIL:

now start the server by clicking on the little green circle (in the servers tab, not the one in the eclipse main icon bar)
IMAGE FAIL:

You should now have a working html server in your computer,
open a new tab and copy the following url
http://localhost:8080/YourProjectName/hello.html
change the YourProjectName to your project name and launch it. you should be running the hello world file on your local tomcat server
When you edit the various files in this tutorial, look up at the name of file in the tab at the top. There will be an asterix to the left of the name signifying unsaved changes have been made. Get ready to hit ctrl-S to save the file, but look down at the servers tab. The full text of the line is
Tomcatv7.0 Server at localhost: [Started,Syncronized]. When you hit the ctrl-S, the last word will change to "republish" for a short time and will then switch back to Syncronized when the file edit changes have been compiled. Eclipse will also remove the asterix next to the file name in the file tab.
Should you wish to force a restart of the server, with a re-compile of the project, that server tab little green circle has become the server restart button. Halting the server is the red square. Or you can right mouse click on the Tomcatv7.0 (the dark blue bar in the image above) and get the popup menu. If you have been doing a lot of editing, and things get wierd, among the things to try is to stop the server, get the popup menu and click on "clean the server directory". One of my friends does this regularly.

The full monty: a .jsp (Java Server Page), .js (JavaScript), .css(Cascading Style Sheet), Java, DWR (Direct Web Remoting),


IMAGE FAIL: With the lib being IMAGE FAIL:


/*******************************************************************************************************/
/****************************** R.java ***************************************************************/
/****************************** R is remote for DWR server side reciever ******************************/
/*******************************************************************************************************/
package webGLTutorials;

//import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.directwebremoting.annotations.RemoteMethod;
import org.directwebremoting.annotations.RemoteProxy;
import org.directwebremoting.annotations.ScriptScope;


/**  R is for Remote.      @author TPMoyer
 *  This was previously named DwrCatcher, but as I got more into javascript I wanted a shorter calling name. */

@RemoteProxy(scope=ScriptScope.APPLICATION)
public class R {
    private static final transient Logger logger = Logger.getLogger(R.class);
    @RemoteMethod
    public void logger(String what){
        //logger.setLevel(Level.DEBUG);
        /**/logger.info(what);
    }

}
/*******************************************************************************************************/
/****************************** a PackageService.java *****************************************************/
/*******************************************************************************************************/
package webGLTutorials;

//import org.apache.log4j.Level;
import org.apache.log4j.Logger;

/** @author TPMoyer */
public class WebGLTutorialsService {
    private static Logger logger  = Logger.getLogger(WebGLTutorialsService.class);

    public StringBuilder GetWebGLTutorials() {
        //logger.setLevel(Level.DEBUG);
        logger.info("cme@ service GetWebGLTutorials");
        StringBuilder sbout = new StringBuilder();
        sbout.append("<div id=tutorialEndings01 style=\"position:relative; top:-100px;\">");
        sbout.append("project is being developed by Thomas P. Moyer Lagrangeville NY    
TPMoyer006@GMail.com       All rights reserved");
        sbout.append("</div>");
        //logger.info("final sbout=\n"+sbout);
        return (sbout);
    }
}
/*******************************************************************************************************/
/****************************** PackageServlet.java ***********************************************/
/*******************************************************************************************************/
package webGLTutorials;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.*;

import org.apache.log4j.Logger;

@SuppressWarnings("serial")
public class WebGLTutorialsServlet extends HttpServlet {
    private static final String primaryOutputJSP = "/webGLTutorials.jsp";
    private static final transient Logger logger = Logger.getLogger(WebGLTutorialsServlet.class);

//  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
////        resp.setContentType("text/plain");
////        resp.getWriter().println("Hello, world from webGLTutorialServlet");
//      //Treat gets and posts as the same
//      doPost(req, rsp);
//  }
    public void doGet(HttpServletRequest req, HttpServletResponse rsp)
    throws ServletException, java.io.IOException {
        //Treat gets and posts as the same
        doPost(req, rsp);
    }

    @Override
    public void doPost(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException {
        //logger.setLevel(Level.DEBUG);
        /**/logger.info("\ncme@ webGLTutorialsServlet.java doPost");
        StringBuilder result_html      = new StringBuilder();

        @SuppressWarnings("rawtypes")
        Map paramMap = req.getParameterMap();
        //logger.info("paramMap has "+paramMap.size()+" values");
        //if(0<paramMap.size())logger.info("URL params are:\n"+req.getQueryString());

        int numHandeled=0;
        /* this cullface is legaciy pulled in from the individual tutorial */
//        boolean cullFace=false;
//        String key= "CullFace";
//        if(paramMap.containsKey(key)){
//            numHandeled++;
//            String[] paramValues = req.getParameterValues(key);
//            if(0<paramValues.length){
//                if(-1<paramValues[0].compareToIgnoreCase("true")) cullFace=true;
//            }
//        }

        if(0==paramMap.size()){
            //logger.info("no params");
        }
        else if(paramMap.size()==numHandeled){
            //logger.info("all params taken in well");
        }
        else{
            @SuppressWarnings("unchecked")Enumeration<String> paramNames = req.getParameterNames();
            logger.info("query included unhandeled params.  Full listing of params is:\n");
            logger.info("param value                           name ");
            logger.info("index index paramame                 length   Value");
            int counter=0;
            while (paramNames.hasMoreElements()){
                String paramName = paramNames.nextElement();
                String[] paramValues = req.getParameterValues(paramName);

                for(int ii=0;ii<paramValues.length;ii++){
                    logger.info(String.format(" %2d    %2d   %-24s   %2d     %-16s",counter,ii,paramName,paramName.length(),paramValues[ii]));
                }
                counter++;
            }
        }
y
        WebGLTutorialsService wgls = new WebGLTutorialsService();
        /* if there was going to be an input form, the calling function could go here */
        result_html.append(wgls.GetWebGLTutorials());  /*pass the value which might have been set by url parameters */
        //logger.info("as recieved back in the servlet: result_html=\n"+result_html);

        //req.setAttribute("form_html",form_html);
        req.setAttribute("result_html",result_html);
        getServletContext().getRequestDispatcher(primaryOutputJSP).forward(req, resp);
    }
}

/*******************************************************************************************************/
/****************************** jdoconfig.xml *******************************************************/
/*******************************************************************************************************/
<!--
<?xml version="1.0" encoding="utf-8"?>
<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig">

   <persistence-manager-factory name="transactions-optional">
       <property name="javax.jdo.PersistenceManagerFactoryClass"
           value="org.datanucleus.api.jdo.JDOPersistenceManagerFactory"/>
       <property name="javax.jdo.option.ConnectionURL" value="appengine"/>
       <property name="javax.jdo.option.NontransactionalRead" value="true"/>
       <property name="javax.jdo.option.NontransactionalWrite" value="true"/>
       <property name="javax.jdo.option.RetainValues" value="true"/>
       <property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/>
       <property name="datanucleus.appengine.singletonPMFForName" value="true"/>
   </persistence-manager-factory>
</jdoconfig>
-->
<div id="placeholder"></div>

/*******************************************************************************************************/
/****************************** log4j.properties *****************************************************/
/*******************************************************************************************************/

log4j.rootLogger=INFO, A1
# A1 is set to be a ConsoleAppender which outputs to System.out. 
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout

# The conversion pattern uses format specifiers. You might want to
# change the pattern an look at the output formats.

# largest, used for file logging, and view on a wide editor, includes times
#log4j.appender.A1.layout.ConversionPattern=%-4r %-5p [%t] %37c %3x - %m%n

# middle width.. sometimes the best solution is a compromize
#log4j.appender.A1.layout.ConversionPattern=%5p (%F:%L) - %m%n

# minimim overhead used for javascript to DWR logger    
log4j.appender.A1.layout.ConversionPattern=# %m%n


# Uncommenting This next section will 
# 1) cause Google App Engine will fail as the project debug-as  server
#       GAE will not allow file writing 
# 2) Apache TomCat server will open a new log file for each server start/restart 
#log4j.rootLogger = INFO, fileout
#log4j.appender.fileout = webGLTutorials.NewLogForEachRunFileAppender
#log4j.appender.fileout.layout.ConversionPattern = %5p (%F:%L) - %m%n
#log4j.appender.fileout.layout = org.apache.log4j.PatternLayout
#log4j.appender.fileout.File = C:/temp/dynamiclogger/logs.log

/*******************************************************************************************************/
/****************************** DWR.xml **************************************************************/
/***** this is where the conneciton to the reciver .java class is made ******************************/
/*******************************************************************************************************/


<!DOCTYPE dwr PUBLIC
    "-//GetAhead Limited//DTD Direct Web Remoting 3.0//EN"
    "http://directwebremoting.org/dwr/dwr30.dtd">

<dwr>
  <allow>
    <create creator="new" javascript="JDate">
      <param name="class" value="java.util.Date"/>
    </create>
    <create creator="new" javascript="R">
      <param name="class" value="webGLTutorials.R"/>
    </create>
  </allow>
</dwr>


/*******************************************************************************************************/
/****************************** logging.properties ***************************************************/
/*******************************************************************************************************/
# A default java.util.logging configuration.
# (All App Engine logging is through java.util.logging by default).
#
# To use this configuration, copy it into your application's WEB-INF
# folder and add the following to your appengine-web.xml:

# <system-properties>
#   <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
# </system-properties>
#

# Set the default logging level for all loggers to WARNING
.level = WARNING

/*******************************************************************************************************/
/****************************** web.xml ************************************************************/
/****************This is the part of the web.xml file you need to add not the full web.xml file**********/
/******** you need one of these servelt blocks for each .jsp which is to be web accesable ************/
/****************************** the dwr stuff is included only once ***********************************/
/*******************************************************************************************************/



       <servlet>
        <servlet-name>WebGLTutorial05Servlet</servlet-name>
        <servlet-class>webGLTutorials.WebGLTutorial05Servlet</servlet-class>
       </servlet>
       <servlet-mapping>
        <servlet-name>WebGLTutorial05Servlet</servlet-name>
        <url-pattern>/WebGLTutorial05</url-pattern>
       </servlet-mapping>
                

       <!-- begin of DWR stuff   -->
       <servlet>
        <display-name>DWR Servlet</display-name>
        <servlet-name>dwr-invoker</servlet-name>
        <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
        <init-param>
        <param-name>debug</param-name>
        <param-value>true</param-value>
        </init-param>
        <init-param>
        <param-name>crossDomainSessionSecurity</param-name>
        <param-value>false</param-value>
        </init-param>
       </servlet>
       <servlet-mapping>
        <servlet-name>dwr-invoker</servlet-name>
        <url-pattern>/dwr/*</url-pattern>
       </servlet-mapping>
       <!-- end of DWR stuff   -->


/*******************************************************************************************************/
/****************************** a .jsp **************************************************************/
/*******************************************************************************************************/
<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.Date"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
<title id="title">Learning webGL — tutorial01</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="<c:url value="css/webGLTutorials.css" />" />
<script type="text/javascript" src="js/jquery-1.9.0.js"></script>
<script type="text/javascript" src="js/gl-matrix.js"></script>     <%--needs to be above gl-aux2.js     --%>
<script type="text/javascript" src="js/gl-aux2.js"></script>
<script type="text/javascript" src="js/sprintf-0.7-beta1.js"></script>
<script type='text/javascript' src="dwr/engine.js"></script>
<script type='text/javascript' src="dwr/interface/R.js"></script>
<script type="text/javascript" src="js/webGLTutorial01.js"></script>

<script id="vertex-shader0" type="text/webgl">
       
       attribute vec3 aXYZ@;
       
       uniform mat4 uMvm@;
       uniform mat4 uPerspectiveMatrix@;
       
       void main(void) {
        gl_Position = uPerspectiveMatrix@ * uMvm@ * vec4(aXYZ@, 1.0);
       }
</script>
<script id="fragment-shader0" type="text/webgl">
       #ifdef GL_ES
        precision highp float;
       #endif
       
       void main(void) {
        gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
       }
</script>


</head>
<body onload="webGLStart01();" style="overflow: auto; overflow-x: hidden;"> 
<p id="breadcrumbs">
         <a href="WebGLTutorials">WebGLTutorials</a> -> WebGLTutorial01
             
         <a href="WebGLTutorial02"> forward to Tutorial02 </a> 
</p>
<h2>Tutorial01   A point, two lines, three lines, a triangle, and two triangles</h2>
<div> 
<canvas id="tutorial01-canvas0" width="500" height="500" style="border:none;"></canvas>
<p id="xyzpry0" class="xyzpry" style="position:relative; left:30px;">xyz=( ###.###, ###.###, ###.###) pry=(###.###,###.###,###.###)</p>
<input type="button" id="cullFace0" style="position:relative; left:190px; top:-15px;" value="  Enable CullFace " ></input> 
</div>
<div style="position:relative; left:502px; top:-561px;"> 
<canvas id="tutorial01-canvas1" width="500" height="500" style="border:none;"></canvas>
<p id="xyzpry1" class="xyzpry" style="position:relative; left:30px;">xyz=( ###.###, ###.###, ###.###) pry=(###.###,###.###,###.###)</p>
<input type="button" id="cullFace1" style="position:relative; left:190px; top:-15px;" value="  Enable CullFace " ></input> 
</div>  
<c:out value='${  form_html}' escapeXml='false'/>
<c:out value='${result_html}' escapeXml='false'/>
</body>
</html>

A java program with logging a new file for each program run


IMAGE FAIL:


/*******************************************************************************************************/
/****************************** a .java program *******************************************************/
/*******************************************************************************************************/
package earth;

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

public class makeSpheresV2_0{
       private static final transient Logger logger = Logger.getLogger(makeSpheresV2_0.class);
       private static final SimpleDateFormat ymdhms=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
       //private static final SimpleDateFormat ymd   =new SimpleDateFormat("yyyy-MM-dd");
       
       private static boolean method(){
        logger.debug("printAsJSONTweenedMultiColoredGuts4(fid="+fid);
        boolean ranWithErrors=false;
        StringBuilder sb = new StringBuilder();
       }
       public static void main(String [] args){
        System.out.println("Started "+new Date());
        boolean ranWithErrors = false;
        /**/logger.setLevel(Level.DEBUG);
        ranWithErrors|=makeTetraHedralSpheres();
       
        if(true==ranWithErrors){
        System.out.println("Done    "+new Date()+"\n                                    AAAAHHHHhhhhhh ranWithErrors."+ymdhms.format(new Date()));
        }
        else{
        System.out.println("Done    "+new Date()+"\nran without Errors. "+ymdhms.format(new Date()));
        }
       }
}



/*******************************************************************************************************/
/****************************** log4j.properties *******************************************************/
/*******************************************************************************************************/
log4j.rootLogger=INFO, A1
# A1 is set to be a ConsoleAppender which outputs to System.out. 
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout

# The conversion pattern uses format specifiers. You might want to
# change the pattern an look at the output formats.

# largest, used for file logging, and view on a wide editor, includes times
#log4j.appender.A1.layout.ConversionPattern=%-4r %-5p [%t] %37c %3x - %m%n

# middle width.. sometimes the best solution is a compromize
#log4j.appender.A1.layout.ConversionPattern=%5p (%F:%L) - %m%n

# minimim overhead used for javascript to DWR logger    
log4j.appender.A1.layout.ConversionPattern=# %m%n


# Uncommenting This next section will 
# 1) cause Google App Engine will fail as the project debug-as  server
#       GAE will not allow file writing 
# 2) Apache TomCat server will open a new log file for each server start/restart 
log4j.rootLogger = INFO, fileout
log4j.appender.fileout = earth.NewLogForEachRunFileAppender
log4j.appender.fileout.layout.ConversionPattern = %5p (%F:%L) - %m%n
log4j.appender.fileout.layout = org.apache.log4j.PatternLayout
log4j.appender.fileout.File = C:/temp/dynamiclogger/logs.log



/*******************************************************************************************************/
/****************************** NewLogForEachRunFileAppender.java **************************************/
/*******************************************************************************************************/
package yourPackageNameHere;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.log4j.FileAppender;
import org.apache.log4j.Layout;
import org.apache.log4j.spi.ErrorCode;

/**
* This is a customized log4j appender, which will create a new file for every
* run of the application.
*
* @author veera | http://veerasundar.com
* Tweeked a bit by TPMoyer(made the file name yyyy-mm-dd-HH-mm-ss instead of System.currentTimeMillis()
* *
*/
public class NewLogForEachRunFileAppender extends FileAppender {

public NewLogForEachRunFileAppender() {
}

public NewLogForEachRunFileAppender(Layout layout, String filename,
        boolean append, boolean bufferedIO, int bufferSize)
        throws IOException {
       super(layout, filename, append, bufferedIO, bufferSize);
}

public NewLogForEachRunFileAppender(Layout layout, String filename,
        boolean append) throws IOException {
       super(layout, filename, append);
}

public NewLogForEachRunFileAppender(Layout layout, String filename)
        throws IOException {
       super(layout, filename);
}

public void activateOptions() {
       if (fileName != null) {
        try {
        fileName = getNewLogFileName();
        setFile(fileName, fileAppend, bufferedIO, bufferSize);
        } catch (Exception e) {
        errorHandler.error("Error while activating log options", e,
        ErrorCode.FILE_OPEN_FAILURE);
        }
       }
}

private String getNewLogFileName() {
if (fileName != null) {
       final File logFile = new File(fileName);
       final String fileName = logFile.getName();
       String newFileName = "";
       int dotIndex=-1;
       SimpleDateFormat ymdhms  = new SimpleDateFormat("yyyy-MM-dd.HH.mm.ss");
       dotIndex=fileName.indexOf('.');
       newFileName = String.format(
        "%s-%s.%s"
        ,-1%lt;dotIndex?fileName.substring(0, dotIndex):fileName
        ,ymdhms.format(new Date())
        ,-1%lt;dotIndex?fileName.substring(dotIndex + 1):""
        );
       return logFile.getParent() + File.separator + newFileName;
}
return null;
}
}

comments and/or suggestions for improvement may be submitted to TPMoyer006@gmail.com