I have a web application running under Tomcat.
Logging for various features is implemented using java.util.logging.
When running tomcat via startup.bat the loggi
As it turns out this is a configuration problem.
When started from the startup.bat tomcat will reference the logging.properties in the conf directory.
When started as a service the jdk/jre/lib logging.properties comes into play.
When running as a windows service, all console output is redirected to stdout.log in the tomcat logs directory .
Attempts to capture logging in custom files with custom logging.properties files have so far failed.
stdout and stderr log files should have been created in the logs directory of your Tomcat installation.
To configure logging use the "Configure Tomcat" application. You can set the error level and the location of the log files there.
When tomcat is started as a service, its default logging configuration actually overrides any application-specific logging configuration. As Aaron suggested the best way to set the configuration is using tomcatw //ES//tomcat_service_name, e.g. tomcat_service_name could be Tomcat5 depending on your installation preferences (also, use tomcatw, not tomcat - both executables can be found in C:\Program Files\Apache Software Foundation\Tomcat 5.0\bin). This post explains how you can ensure that you use the correct service name (if there are no values in the dialog then the name is probably incorrect).
I would post an image but I do not have sufficient rep. On the Java VM tab, enter the configuration in Java Options, e.g. -Dlog4j.configuration=service.log4j.properties
The file that contains your logging configuration can then be placed in tomcat server classes directory, e.g. C:\Program Files\Apache Software Foundation\Tomcat 5.0\server\classes.
There are several places where you can put the logging configuration file. I initially tried specifying a full path for the logging configuration file but log4j appears to check only certain paths. As this post states, place -Dlog4j.debug as the first line in Java Options and you can debug what log4j is doing. The server classes directory is listed as one possible search path.
When creating your log4j.properties file, name it something other than log4j.properties, e.g. service.log4j.properties. Naming it log4j.properties runs the risk that an application-specific log4j.properties file could be found, which would override your configuration but, which would then be subsequently ignored by the tomcat service.
This is probably a permissions issue when using Tomcat 9 on windows.
The service.bat install
tool from the bin folder of tomcat is registering tomcat as a local service account.
This account type doesn't have enough permissions (among which writing its log files and compiling jsps). To fix this you can change the service account type and use a local user account to run the service.
Alternatively the account can be changed to a local system acocunt (which used to be the case for the service installer), but due to security reasons, this is no longer recommended.
See also Tomcat Service gets installed with “Local Service” account
Make sure that the Tomcat environment is the same in both cases. Check the paths and settings in the Tomcat service editor. Don't use the standard Windows properties dialog for services but start tomcat.exe with //ES//name
where name
is the name of the service.