Server Logging
From Multiverse
| Multiverse Servers |
|
Installing • Installing on Linux • Running • Troubleshooting • FAQ • Release Notes • Updating • JMX Monitoring & Mgmt. |
| Infrastructure |
|
Platform Architecture • Registering a World • Proxy Server • Event Handling • World Manager • Voice Server |
| Messaging System |
|
Perception Messaging • Using Extension Messages • Message Marshalling • Multi-subject Messaging • Message Catalog |
| Object Architecture |
|
World Instancing • Server Object Search • Server Regions • Server Markers |
| Scalability and Performance |
| Reference |
|
File Layout • Property File • Logging • API |
Contents |
Overview
The Multiverse servers use the Apache Log4j package for logging. You control logging through properties in the properties file and via statements in server Python scripts.
Log files
By default, log files are in the mv-home/logs/ directory. So, if you installed the servers in C:\multiverse, the log files for Sampleworld will be in C:\multiverse\logs\sampleworld.
The default log file names are set in the server start script (multiverse.sh or start-multiverse.bat) with the multiverse.loggername system property (passed in via -D on the Java command line when starting the server processes):
- Combat server:
combat.out - Message domain server:
domain.out - Login manager:
login_manager.out - Mob server:
mobserver.out - Object manager:
objmgr.out - Proxy server:
proxy_1.out - World manager:
wmgr_1.out - Instance server:
instance.out - Startup monitor:
startup.out - Voice server:
voiceserver.out
NOTE: As explained below, the default configuration appends ".1", ".2", and so on to older log files from previous server sessions (for example, combat.out.1). The most recent log files will always have just the ".out" extension.
Setting log levels
The log level determines what messages are sent to the log files.
Global default log level
Set the global default log level of the server in the Multiverse property file with the following property:
multiverse.log_level=level
Where level is an integer between zero (0) and four (4). The default is one (1). For example:
multiverse.log_level=1
Individual server log levels
To set the log level for an individual server, use the following statement in Python script for the server:
Log.setLogLevel(level);
where level is an integer between zero (0) and four (4), inclusive. Specifying log level in this way is optional; if not set, the log level is the global default.
Log levels
The following table describes the five log levels.
| Multiverse Log Level | log4j Level | Description |
|---|---|---|
| 0 | TRACE | Designates finer-grained informational events than the DEBUG |
| 1 | DEBUG | Designates fine-grained informational events that are most useful to debug an application. |
| 2 | INFO | Designates informational messages that highlight the progress of the application at coarse-grained level. |
| 3 | WARN | Designates potentially harmful situations. |
| 4 | ERROR | Designates error events that might still allow the application to continue running. |
Rotating log files
In the default configuration, the Multiverse servers will rotate their log files each time they are restarted. An existing log file is renamed name.out.1 and the current session is logged to name.out, where name is the log file name. Subsequently, the server moves name.out.1 files to name.out.2, and so on.
If you want the servers to append onto an existing log file when they start, change the multiverse.rotate_logs_on_startup property from true to false:
multiverse.rotate_logs_on_startup=false
Deleting log files
To delete the current log files each time the server starts, set the multiverse.delete_logs_on_startup property to true:
multiverse.delete_logs_on_startup=true
Log4j configuration
Use the following properties to configure other logging behavior. See Apache Log4j for more information.
Log file directory and file names
The following property specifies the directory and file names to which to save the log files:
log4j.appender.FILE.File = ${multiverse.logs}/${multiverse.loggername}.out
The values for the multiverse.logs and multiverse.loggername system properties are specified in the startup scripts and passed through the Java command line to the Multiverse servers.
Log file rotation
The log4j.appender.FILE properties enable you to "rollover" log files when they reach a certain size (default is 20MB) and specify how many backup files to save (default is one). The default settings are
log4j.appender.FILE = org.apache.log4j.RollingFileAppender log4j.appender.FILE.MaxFileSize = 20MB log4j.appender.FILE.MaxBackupIndex=1
For more information, see org.apache.log4j.RollingFileAppender.
To rollover the log files at regular intervals, use DailyRollingFileAppender.
Format of log messages
These two properties specify the format of the log messages
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%-5p [%d{ISO8601}] %-20t %m%n
For more information, see org.apache.log4j.PatternLayout. You can use other layout classes to create different layout formats. For example:
- org.apache.log4j.xml.XMLLayout to format the logs in XML
- org.apache.log4j.HTMLLayout to format the logs as an HTML table.
Creating an error log
It can be troublesome to search very large log files for errors; to avoid this, you can configure logging to create special log files that contain only ERROR lines and associated stack traces.
Modify your multiverse.properties file as follows:
###
### log4j configuration. The multiverse.log_level over-rides the
### log4j log level.
###
log4j.appender.FILE = org.apache.log4j.RollingFileAppender
log4j.appender.FILE.File = ${multiverse.logs}/${multiverse.loggername}.out
log4j.appender.FILE.MaxFileSize = 50MB
log4j.appender.FILE.MaxBackupIndex=3
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%-5p [%d{ISO8601}] %-20t %m%n
#log4j.rootLogger=DEBUG, FILE
###
### Special Error check file
###
log4j.appender.ERRFILE = org.apache.log4j.RollingFileAppender
log4j.appender.ERRFILE.File = ${multiverse.logs}/${multiverse.loggername}_error.out
log4j.appender.ERRFILE.MaxFileSize = 50MB
log4j.appender.ERRFILE.MaxBackupIndex=1
log4j.appender.ERRFILE.Threshold=ERROR
log4j.appender.ERRFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.ERRFILE.layout.ConversionPattern=%-5p [%d{ISO8601}] %-20t %m%n
log4j.rootLogger=DEBUG, FILE, ERRFILE
The important thing for the ERRFILE is the Threshold definition. It allows you control what kinds of messages go in there. I hope you all enjoy this as much as I do..
Using an external log viewer
The Vigilog log file viewer is a free application for viewing log4j log files. It allows you to open your log files initially while the server is running and then hit refresh to update them. It has highlighters and allows you to click on an abbreviated list to open up specific error tracking.
To use Vigilog, you must change the following line in your multiverse.properties file:
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
to
log4j.appender.FILE.layout=org.apache.log4j.xml.XMLLayout
You must also comment out the following line:
# log4j.appender.FILE.layout.ConversionPattern=%-5p [%d{ISO8601}] %-20t %m%n
Alternatively, you can create a new log4j appender for XML output so the default text logs are still available.
