Some of the logging configuration changes that you might want to make include:
• 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, while appropriate for a development environment, is not optimal for a production environment. In production you should specify a rolling log file, which when it reaches a certain size creates a new log file. Listing 1 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 of the changes are highlighted.
Listing 1 Defining a rolling log appender
01.<log4j:...>02. <appender name="FILE"03. class="org.jboss.logging.appender.RollingFileAppender"> #104. <errorHandler .../>05. <param name="File" value="${jboss.server.log.dir}/server.log"/> #206. <param name="Append" value="true"/> #307. <param name="MaxFileSize" value="10MB"/> #408. <param name="MaxBackupIndex" value="20"/> #509. <layout .../>10. appender>11. ...12.log4j>#1: Changed to use the rolling appender
#2: Location of log file
#3: Append to existing file on startup
#4: Limit log file size to 10MB
#5: Keep only the last 20 log files
We did not 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 subclasses of the Log4J appenders defined in the org.apache.log4j package that automatically create the server/xxx/log directory.
The system property jboss.server.log.dir defines the location of the log file (#2).
No comments:
Post a Comment