JBoss Community

Logging for JBoss Application Server 7 Subsystems

modified by James Perkins in JBoss AS7 Development - View the full document

General Rules:

  • All exceptions and messages require a translation method in the @MessageBundle.
  • All info and higher messages being logged require a translation method in the @MessageLogger.
  • Messages in both the @MessageBundle and @MessageLogger should have an id*.  Note though there are cases, specifically some methods in the @MessageBundle, that do not need id's. These typically include messages that are not being used in exceptions.

 

* A list of id's can be found here http://community.jboss.org/wiki/LoggingIds

 

Examples:


Before:

@Override
public void start(StartContext context) throws StartException {
    try {
        final JBossThreadFactory threadFactory = new JBossThreadFactory(new ThreadGroup("ServerDeploymentRepository-temp-threads"), Boolean.FALSE, null, "%G - %t", null, null, AccessController.getContext());
        tempFileProvider = TempFileProvider.create("temp", Executors.newScheduledThreadPool(2, threadFactory));
    } catch (IOException e) {
        throw new StartException("Failed to create temp file provider");
    }
    log.debugf("%s started", ServerDeploymentRepository.class.getSimpleName());
}

 

Methods added to DeploymentRepositoryMessages:

/**
 * Creates an exception indicating a failure to create a temp file provider.
 *
 * @return a {@link StartException} for the error.
 */
@Message(id = 14900, value = "Failed to create temp file provider")
StartException failedCreatingTempProvider();

 

After:

@Override
public void start(StartContext context) throws StartException {
    try {
        final JBossThreadFactory threadFactory = new JBossThreadFactory(new ThreadGroup("ServerDeploymentRepository-temp-threads"), Boolean.FALSE, null, "%G - %t", null, null, AccessController.getContext());
        tempFileProvider = TempFileProvider.create("temp", Executors.newScheduledThreadPool(2, threadFactory));
    } catch (IOException e) {
        throw MESSAGES.failedCreatingTempProvider();
    }
    ROOT_LOGGER.debugf("%s started", ServerDeploymentRepository.class.getSimpleName());
}

Comment by going to Community

Create a new document in JBoss AS7 Development at Community