JwsContext.getLogger(String) Method

Gets an instance of the Logger class, which you can use to send messages from your code to a log file.

# Syntax

    public Logger getLogger(String categoryName)

# Parameters

categoryName

The name of the category by which log messages should be grouped.

# Return Value

A Logger class that may be used to send messages to the application log.

# Exceptions

None.

# Remarks

Use getLogger to log messages from your web service Java code to a text file. By default, for the domain in which you develop and debug WebLogic Workshop web services, this text file is located at the following path of your WebLogic Workshop installation:

BEA_HOME/weblogic700/samples/workshop/jws.log

Use the categoryName parameter to specific text that will be included with log entries. For example, you might specify the name of the JWS file so that you can more easily find relevant messages when scanning the log file. A log message my appear as follows for an entry in which categoryName is "MyService".

    16:18:11 ERROR MyService    : My log message.

Note: You can customize aspects of the logging configuration, including the name of the application log file, its size limit, and so on. You configure logging using the workshopLogCfg.xml file. For more information, see workshopLogCfg.xml Configuration File.

The Logger class returned by the getLogger method includes four methods that you can use to print log entries to a text file. Each of the methods is available in two variations -- one that simply sends a message and another that sends an message and the contents of an exception or error (in effect, any class that inherits from Throwable).

##### debug Method

    void debug(String)
    void debug(String, Throwable)

Not surprisingly, you should use the debug method to log messages for debugging. These are debugging messages that you might otherwise write to a command console using System.out.println(). The advantage of debugging using logs is that logged messages can be kept and stored; with a console, you must copy and paste messages into a text file to store them.

Before deploying your web service, however, you should either remove code for debugging or ensure that the production service is configured not to log debugging messages. Logging messages for debugging can unnecessarily bloat a message log.

##### info Method

    void info(String)
    void info(String, Throwable)

Use the info method to log informational messages that highlight the progress of your web service.

##### warn Method

    void warn(String)
    void warn(String, Throwable)

Use the warn method to log messages about potentially harmful situations.

##### error Method

    void error(String)
    void error(String, Throwable)

Use the error method to log error events that might still allow the service to continue running.

Note: The Logger class returned by the getLogger method is part of the log4j package available from the Jakarta project. For general information about log4j, see log4j project. For information about the log4j application programming interface (API), see Short Introduction to log4j.

Related Topics

workshopLogCfg.xml Configuration File