The easiest way to turn logging on in Listener 2.0.1 is to use Oracle SQL Developer to turn on the debug.debugger
setting:
View|APEX Listener
from the main menuListener
and choose Connect...
Listener>Administration>Global Settings>Environment>Error Reporting
node. Tick the Show debug messages on the console
option.Upload
button from the toolbar (5th from left), and click yes to confirm the upload.Alternatively if your prefer you can edit the defaults.xml
Listener configuration file directly. Adding the following to the file to enable logging:
|
|
You must restart the Listener instance after editing defaults.xml
manually.
Listener can be configured to display the log information in the error page that is displayed whenever an error occurs. This is very useful in development environments for quickly seeing why a request failed. Note it must not be enabled in production environments, because the logging information will likely reveal sensitive information. To enable this setting using SQL Developer:
View|APEX Listener
from the main menuListener
and choose Connect...
Listener>Administration>Global Settings>Environment>Error Reporting
node. Tick the Show error messages in the browser
option.Upload
button from the toolbar (5th from left), and click yes to confirm the upload.Alternatively if your prefer you can edit the defaults.xml
Listener configuration file directly. Adding the following to the file to enable logging:
|
|
You must restart the Listener instance after editing defaults.xml
manually.
If just logging debug messages to the console is not appropriate for your environment (perhaps you need your logs formatted to a particular standard, or you need to configure log file rotation policies), then you can configure how Listener logs messages via the standard Java Logging Service (java.util.logging
) provided by the Java runtime.
The debug.debugger=true
setting takes precedence over the Java Logging Service. If debug.debugger=true
then the detailed diagnostic messages produced when processing a request will be logged directly to the console rather than being forwarded to the Java Logging Service. Therefore it is recommended that when you using the Java Logging Service to set debug.debugger=false
or remove the debug.debugger
setting from defaults.xml
The rest of this post will concentrate on configuring logging when running in Standalone Mode, subsequent posts will describe adapting the techniques described below to work in WebLogic and GlassFish environments. The JRE logging service is configured via a standard properties file typically named: logging.properties
, below is a simple example that logs everything to the console, and logs all classes at the most verbose level:
|
|
Any JRE can have it’s logging service configured via the java.util.logging.config.file
system property, the value of the property being the path to the logging.properties
file. Assume logging.properties
is located in /usr/local/apex/listener/conf
, then you would tell the Listener to use this file as follows:
|
|
If you try this using the sample configuration file shown above, you will see a huge volume of information printed to the console. Log messages for all java components involved in processing a request will appear in the console, including messages from: Grizzly, the embedded web server used in Standalone Mode, the Oracle JDBC Driver, and the Oracle Universal Connection Pool library, amongst others. There is so much information logged that it becomes almost impossible to focus on the information that we’re actually interested in, so let’s re-configure logging.properties
to focus in on reporting messages from the Listener only, while still letting us know if an error occurs in any of the other components:
|
|
Now if you try the above configuration you will notice a lot of information will still be logged, but it’s focused on messages produced by the Listener so it’s easier to follow, it’s a very similar level of information to that produced by the debug.debugger=true
setting. For production environments you will likely want to reduce the verbosity of the logs even further, typically to only report warning or error conditions, so change the oracle.dbtools.level
setting as follows:
|
|
If you want to log to a file instead of the console change the handlers
setting, and add the extra settings required for a file logger:
|
|
If you want to log to both a file and the console you can do something like the following:
|
|
For more information on the Java Logging Framework see: The JDK logging documentation. The java.util.logging.FileHandler
log handler has several more configuration options not shown in these examples (such as configuring file rotation) see here for more information.