-
Notifications
You must be signed in to change notification settings - Fork 1
Logging
This section describes internal server logging mechanisms and the way to set up additional logs for project purposes.
In both cases of slave servers and cache server, logging is done exactly the same with log()
calls from either CacheServer
or Server
classes. The underlying Logger
class has a separate thread with a queue attached for writing messages to disk drive. In case of slave servers the Logger
instance is per metaserver, not per main server thread.
Logging is done with the CacheServer.log()
or the Server.log()
method. This method forwards the call to the instance of Logger
class. It accepts three arguments - message type, message contents and an optional flag for logging exception stack. The message type is a string that can be either custom or one of two special cases - "trace" and "stats". "trace" log messages will be copied into separate trace logs for convenience, same with "stats" messages. There is also a simplified CacheServer.stats()
/Server.stats()
method for that purpose described in Real-time Stats article.
Each of the common, trace and stats logs go into a separate directory. When server runs in normal mode, these directories are "logs/", "trace/" and "stats/". In case of uniserver mode, these directories have a server type attached. For example, game server logs will be in "logs.game/", "trace.game/" and "stats.game/" directories, respectively. Cache server logs are treated as a "cache" type ("logs.cache/", etc).
Every hour the log messages will be written into another logfile. The naming scheme for logfiles is <year>-<month>-<day>-<hour>.txt
(YYYY-MM-DD-HH.txt
).
The logs are controlled by two configuration variables - server.printLog
and server.writeLog
.
The underlying Logger
class functionality is available for project use. Its constructor accepts a single argument with parameters object of type _LogParams
. Let's see what it has to offer.
Property | Description |
---|---|
name | Logger thread name. Logger thread name will be set to logger: <name> . |
printLog | Enables log printing to stdout. |
writeLog | Enables writing log to disk. |
isHourly | If true, will create a new log file every hour. If false, every day. |
logFull | If true, will add date and message type to log before each message. |
doFlush | If true, will call flush() after each log message. That slows logging down, so use it only for light cases. |
directory | Logfiles directory. If set to null, will use "logs/" instead. |