Logging is used by different people for different things:
These groups of people want:
The quality of the message texts can be checked for being meaningful and being correct English by QA or Documentation by looking at the properties bundles.
The available log levels should be used as follows:
| Level | Frequency | When | Example |
|---|---|---|---|
| SEVERE | Rarely | The system is in critical need of attention. To resolve this error, the administrator MUST undertake action. | Component could not start because of a missing configuration file; application could not be deployed because an object is not bound to JNDI; a message could not be sent because of a missing certificate. |
| WARNING | Ideally not more than once every few seconds | An error occurred; the error may recover itself. | Failed to connect to an external system, retry attempts will be made; message could not be sent because it contained invalid data |
| INFO | At most a few times in the application's or container's lifecycle | The system as a whole has changed state. | An inbound connector will now receive messages from an external system |
| CONFIG | see INFO | A system wide of application wide configuration change has happened | The transaction time out was changed to 50 seconds. |
| FINE | Per log message: about once for each transaction | debugging and diagnostics | Loading certificate a.cer from store c:\yyy.store |
| FINER | Multiple times per transaction | debugging and diagnostics | Sending block 982 out of 1000 |
| FINEST | Unlimited | debugging | Received 5 bytes, state = 0 |
Custom log levels should not be added due to a bug in JDK logging.
See NDC blog entry
for more information and immediate use of this feature in SJSAS.
Components should list the loggers they use in their jbi.xml, including the ones for which ComponentContext.getLogger(name) is called and the library loggers for which Logger.getLogger(name) is called.
The JBI runtime provides MBeans for each for of the loggers associated with a component; these loggers are visible in NetBeans and the admin console and can be manipulated through there. The JBI runtime does not persist logging changes. In fact, the JBI runtime should delegate manipulation of loggers to the SJSAS runtime so that they are persisted in domain.xml together with settings of other loggers.
Loggers that have names that end in -once will exhibit this behavior.
The user should be able to specify filters that take into account the NDC, level, and log categories.
Example:
sLog.info(I18N.x("E001: The component with name [[{0}] could not be "
+ "unloaded after {1} tries, the last error was: {2}", name, Integer.toString(i), e), e);
which results in this log message:
XYZBC-E001: The component with name [test] could not be unloaded after 5 tries, the last error was: XYZBC-E002: File [a/b/c/d/] could not be deletedThe properties bundle XYZBC-msgs.properties generated as part of the build contains:
# com.sun.jbi.xyzbc.core.LifecycleManagement:
E001: The component with name [[{0}] could not be unloaded after {1} tries, the last error was: {2}
A way to enforce internationalized messages is to introduce a special String class that represents a localized message. Log wrappers around the java.util.logging.Logger class only accept these localized messages. Likewise, custom exception classes or helper methods to throw exceptions are helpful if they only accept localized string objects.
The I18N build tool and log wrappers / exception helpers that only accept localized messages was used successfully in JMSJCA.
See I18N blog entry
for more information on how to use this tool and where to get it.
Action items:
Wrong:
} catch (Exception e) {
throw new ApplicationException(I18N.x("E123: method failed"));
}
Right:
} catch (Exception e) {
throw new ApplicationException(
I18N.x("E123: Webservice {0}({1}) could not be invoked: {2}", methodname, argarray, e)
, e);
}
if (sLog.isLoggable(Level.FINEST) {
sLog.fine("Received message with id = " + messageid);
}
The idea of doing it this way that the object creation due to the string concatenation is avoided by first checking if the message would be logged in the first place.
The web console log viewer should be extended with more filtering capabilities so that the log stream can be filtered based on application name, request id (Post Sierra), thread name (Post Sierra), etc. It should be possible to hide stack traces and to unhide stack traces.
(Post Sierra) Several people in the field have expressed interest in a log viewer that could quickly filter out messages, correlate messages on the same thread, etc. It may be possible to have this task done by the community (Frank wrote a viewer years ago that meets most of these requirements).
The other changes such as an improved log level management page is not a show stopper, neither is the log viewer. So it simply means that these changes will be pushed to a subsequent release.
| Importance | What |
|---|---|
| Critical | Support for NDC |
| Important | Improvements in the logging management page |
| Nice to have | Support for separate log files |
| Nice to have | Support for only-once-per-file messages |
| Important | Work with SJSAS team to fix existing bugs in logging configuration page |
| Nice to have | Duplicate stacktrace removal |
| Nice to have | Stand alone log viewer; see EM requirements for web based log viewer |
| Importance | What |
|---|---|
| Critical | adherence to component requirements |
| Critical | Loggers in jbi.xml |
| Important | Change in JBI runtime: runtime/manage/src/com/sun/jbi/management/support/DefaultLoggerMBeanImpl.java should call SJSAS MBean method to set log level instead of Logger.setLevel(). |
| Critical | Parts of the JBI runtime currently don't have a unique msgid; needs fixing |
| Critical | Parts of the JBI runtime currently print stacktraces to the console (end up in the log file); needs fixing |
| Importance | What |
|---|---|
| Nice to have | Although the Classic CAPS components don't use resource bundles nor do they use unique ids, Classic CAPS components will not be modified to comply with all of the logging guidelines. Some of the worst offending log messages may be changed if enough resources can be found to change them. |
| Importance | What |
|---|---|
| Critical | The JBI components currently don't have a unique msgid; needs fixing. |
| Critical | Use NDCs for those components for which it makes sense |
| Critical | Minimum trace messages |
| Critical | JBI Components should list all loggers in jbi.xml |
| Importance | What |
|---|---|
| Critical | Assuming that the EM console will be integrated into Glassfish and into the Glassfish console, need to determine if the log viewer in EM is going to replace the log viewer in SJSAS or vice versa. |
| Critical | Log viewer should filter based on application |
| Nice to have | Log viewer should filter based by request ID or message ID |
| Critical | Log viewer should have the ability to hide or unhide stacktraces |
| Critical | Log viewer (EM) should be fully stable (past (?) instabilities have turned off many users from using EM log viewer) |
| Nice to have | Log viewer should page faster |
| Nice to have | Log viewer should be faster in use with respect to setting up filters, etc |
| Importance | What |
|---|---|
| Critical | Finish guidelines |
| Critical | Have sessions with developers to ensure everybody is aware of these guidelines. |