• No results found

33Configuring the application server

Managing the JBoss Application Server

33Configuring the application server

Various MBeans related to accessing JMX services.

Various MBeans related to the remoting service—Enable remote access to local ser-

vices. These services play a role in almost all remote access to the application

server, including messaging and EJB access.

2.2

Configuring the application server

Besides the jboss-service.xml file covered in the previous section, services deployed to

the application server can embed a META-INF/jboss-service.xml into their archives or

a separate *-service.xml file that declares the MBeans for that service. For example,

the Universally Unique ID (UUID) generator defines its MBeans in the server/xxx/

deploy/uuid-key-generator.sar/META-INF/jboss-service.xml file. As another example,

the various *-service.xml files found in the server/xxx/deploy/messaging directory

define the MBeans used by the messaging service.

These configuration files aren’t the only ones used to configure services. Each ser-

vice can define its own configuration file(s), beyond the XML files used to define the

MBeans for the service. For example, the server/xxx/conf directory contains many

configuration files, which are described in table 2.1.

Table 2.1 Files in the conf directory

File Description

bootstrap.xml Used by the microcontainer to load the initial set of POJOs. This file is a master file that includes the following files: aop.xml, classloader.xml, deployers.xml, jmx.xml, and profile.xml.

jacorb.properties Used to configure the Java Object Request Broker (JacORB) service, which is used when clustering application servers.

jax-ws-catalog.xml Used to map XML metadata names to local metadata descriptor files—both Document Type Definition (DTD) and XML Schema Definition Language (XSD)—in the docs/dtd and docs/schema directories. This is a required catalog to support Java API for XML-based Web Services (JAX-WS). jbossjta-properties.xml Used to configure the Java Transaction API (JTA) service.

jboss-log4j.xml Used by the logging service to define the logging settings.

jboss-minimal.xml A variation of the jboss-service.xml file configured for a minimal applica- tion server configuration. This file is never used.

jboss-service.xml Used by the JMX kernel.

jndi.properties Used by the JNDI service to define default properties.

login-config.xml Used by the security service to define login modules. standardjboss.xml Used by the EJB service to define configuration settings.

standardjbosscmp-jdbc.cmp Used by the EJB service to define type mappings for various databases for use with Container Managed Persistence (CMP) for EJB 2.x entity beans.

We cover many of the configuration files in other chapters in this book, but there are a few that we don’t cover later that are worth looking at here. The topics we examine include configuring logging, configuring directory locations using system properties, and defining additional system properties.

2.2.1 Configuring logging

The application server uses log4j, an open source logging framework, to do logging. The log4j configuration file is located at server/xxx/conf/jboss-log4j.xml.

By default, two appenders are defined: one for the console, which is set to log entries identified as level info or higher priority, such as warning and error entries; and one for the server/xxx/log/server.log file, which is set to log all levels. In addi- tion, various category settings define the trace level for various packages to limit the amount of logging accomplished.

Some of the logging configuration changes that you might want to make include the following:

■ Specifying a rolling log file

■ Limiting the amount of logging produced

■ Adding logging for your application

■ Defining a new log file

Each of these topics is covered in the following text.

ROLLING THE SERVER LOG FILE

The server.log file is created new each time the server is launched, and grows until the server is stopped or until midnight. This behavior, although appropriate for a develop- ment environment, isn’t optimal for a production environment. In production, you should specify a rolling log file that creates a new log file when it reaches a certain size. Listing 2.2 shows how you can change the appender for the server.log file to create, at

most, 20 log files of 10 megabytes (MB) in size each. All the changes are highlighted.

<log4j:...> <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender"> <errorHandler .../> <param name="File" value="${jboss.server.log.dir}/server.log"/> <param name="Append" value="true"/> <param name="MaxFileSize" value="10MB"/> <param name="MaxBackupIndex" value="20"/> <layout .../>

</appender> ...

</log4j>

We didn’t change the errorHandler or layout settings from the default. By the way, the

various appenders defined in the org.jboss.logging.appender package are simple

Listing 2.2 Defining a rolling log appender

Uses rolling appender

B

Location of

log file

Keeps only last 20 log files Limits log file size to 10 MB Appends to existing file on startup

35