Cloud Documentation
Advanced Search


Using Oracle Java Cloud Service
Close Window

Table of Contents

Show All | Collapse

4 Frequently Asked Questions for Oracle Java Cloud Service

This section provides answers to frequently asked questions (FAQ) for configuring and using Java Cloud Service. This technical FAQ supplements the more general Java FAQ on the Oracle Cloud website, at the following address: http://cloud.oracle.com/java.

Topics:

How do I create an on-premise WebLogic Server environment that is comparable to a Java Cloud Service instance?

An on-premise environment is a local WebLogic Server/Java EE environment that is comparable to a Java Cloud Service instance. An on-premise environment is useful for both developing and troubleshooting applications deployed to Java Cloud Service. For more information, see Creating an On-premise WebLogic Server Environment.

Can I set Log4j or JDK logging levels for my applications?

In the current release, logging levels can only be set programmatically. Here are examples of setting log levels for the Log4j and JDK loggers in your application code.

Setting Log4j Logger Levels

Note that setting the logger to level.INFO is not enough to log a trace.

org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Log4jLoggingServlet.class.getName());

        try {
            throw new Exception("Trace example: This is an exception. This
will not be logged.");
        } catch (Throwable e) {
            logger.setLevel(Level.INFO);
            logger.trace(e.getMessage(), e);
        }

Instead, you must set the logger to level.TRACE.

try {
            throw new Exception("Trace example: This is an exception. This
will be logged.");
        } catch (Throwable e) {
           
            logger.setLevel(Level.TRACE);
            logger.trace(e.getMessage(), e);

Setting JDK Logger Levels

Note that setting the logger to level.INFO is not enough to log a trace.

java.util.logging.Logger logger = java.util.logging.Logger.getLogger(LoggingServlet.class.getName());

        try {

            throw new Exception("Trace example: I will not appear in the
log.");
        } catch (Throwable e) {
            logger.setLevel(Level.INFO);
            logger.throwing(LoggingServlet.class.getName(), "doGet", e);
        }

Instead, you must set the logger level to level.FINER.

try {
            throw new Exception("Trace example: Level has to be finer for me
to appear in the user log.");
        } catch (Throwable e) {
            logger.setLevel(Level.FINER);
            logger.throwing(LoggingServlet.class.getName(), "doGet", e);

If I'm using the JDeveloper IDE can I use Log4j with applications deployed to Java Cloud Service?

Yes, however, Log4j is not part of the libraries available in JDeveloper, so you would need to explicitly download and include the Log4j library into your application.

Do I need to put my Log4j properties files in a particular location?

Oracle Cloud does not affect Log4j's mechanism for locating its own configuration files; therefore, the location of Log4j properties files should be by default found on the system CLASSPATH. Please refer to the Log4j documentation for configuration file information. For more information, see Guidelines for Applications When Accessing System Properties.