//
GlassFish, REST Data Services

Configuring Logging with Oracle Application Express Listener and GlassFish

In the previous post, we showed how Listener can use the Java Logging Service to configure where diagnostic information is logged and how it is filtered. We also showed how you can configure the logging service in Standalone Mode using the -Djava.util.logging.config.file JVM option. Configuring logging via the JVM option works perfectly well for Standalone Mode, because in that case Listener is the only application running in the JVM. Conversely using the JVM option does not work so well when using a proper application server like GlassFish or WebLogic, for a couple of reasons:

  • The JVM option only allows the logging configuration to be specified at JVM startup, there’s no way to change the log configuration on the fly
  • There will often be many applications deployed on the application server at the one time, changing the configuration can end up affecting every application on the server, not just the Listener

Fortunately application servers enhance the Java Logging service and provide facilities to change the Listener logging configuration on the fly. In this post we’ll be looking at the logging configuration facilities that GlassFish provides and how they can be leveraged to control Listener logging.

For the examples below we are going to assume your Listener is instance is deployed at:


http://localhost:8080/apex/

and your GlassFish Administration Console is deployed at:


http://localhost:4848

Adjust these values for your local environment.

Disable debug.debug

As mentioned in the previous post, when using the Java Logging Service with Listener, it’s important that the defaults.xml debug.debugger configuration setting is disabled, as when it is enabled it overrides the Java Logging Service and log messages are printed directly to the console. Refer to the previous post for instructions on how to do this.

Access the GlassFish Administration Console

Enter the following URL in your browser:


http://localhost:4848

If you have configured a password, enter your credentials.

Navigate to the Logging Configuration Pages

In the navigation tree on the left of the page, expand the Configurations node, then expand the server-config node. Now click the Logger settings node. On the General tab you can configure the basic logging parameters, we’re not going to change anything here, consult your GlassFish documentation if you want to learn more.

Next click on the Log Levels tab. Click the Add Logger button. Enter oracle.dbtools as the Logger Name and then set the log level you want, for example to show all messages choose ALL and then press the save button.

Now to try out your changes, open another browser window and enter the following URL:


http://localhost:8080/apex/

Keep an eye on the GlassFish console, you should see lots of information being printed as the APEX login page appears. Now switch back to the GlassFish Administration console and switch the log level for oracle.dbtools to OFF. Next try accessing the URL above again, this time nothing should be printed to the console, thus demonstrating how you reconfigure Listener logging on the fly without needing an application restart, just one of the benefits of deploying Listener in an application server, versus running in standalone mode.

About these ads

Discussion

Comments are closed.

Twitter

The views expressed on this blog are my own and do not necessarily reflect the views of my employer.

Archives

Follow

Get every new post delivered to your Inbox.

Join 94 other followers