How to configure your web application's stderr and stdout messages be redirected to the application's log file for Tomcat 5.5 in ERS 3.x
For standard web applications, error messages and output are streamed to log files using sterr and stdout respectively. Some application developers prefer to aggregate all these messages into the application log.
The following steps are required to configure your web application's stderr and stdout messages be redirected to the application's log file for Tomcat 5.5 in ERS 3.1 utilizing java.util.logging:
1. Add the following attribute to the application context in <ERS3.1_install_dir>/servers/<server_instance>/conf/context.xml file:
swallowOutput="true"
2. Create <ERS3.1_install_dir>/servers/<server_instance>/webapps//WEB-INF/classes/logging.properties with the following content:
handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler ############################################################ # Handler specific properties. # Describes specific configuration info for Handlers. ############################################################ org.apache.juli.FileHandler.level = FINE org.apache.juli.FileHandler.directory = /servers//logs org.apache.juli.FileHandler.prefix = jsp-examples. java.util.logging.ConsoleHandler.level = FINE java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
NOTE: In the above example, the application log file with prefix jsp-examples. will be created in the server instance's logs directory.
3. To test the configuration, create a JSP page with the following content:
<%
System.out.println("Test stdout");
System.err.println("Test stderr");
%> The stderr and stdout would continue to be logged in jvm.stdout, they are also logged in the application's log file.
Popular Links
Comments
rfc
Can you please clarify if this /servers/ refers to a tomcat directory?
thanks
Post new comment