Class LogService


  • @Service
    public class LogService
    extends Object
    Support for per-game logging. Two logs are generated: a trace log, and a state log. The trace log is called "hhhxxx.trace" where hhh is the prefix provided as the argument to setPrefix(), and xxx is the id if the Competition instance. Ideally, hhh is the hostname of the machine running the sim.

    The contents of the trace are intended to be error, warn, info, or debug messages that help developers or users understand what the server is doing. Loggers are named after the classes in which they are generated. Each class that will use a logger must include a statement

      static private Logger log = Logger.getLogger(ClassName.class.getName());
     
    where ClassName is the name of the class.

    The state log is a record of state changes, intended to allow complete reconstruction of a simulation. You get one with the statement

      static private Logger stateLog = Logger.getLogger("State");
     
    Entries in the state log are of the form
      type:class:id:op:arg1:...
     
    where type is one of [c,u,d] for create, update, delete; id is the identifier of the object, op (used only for update) is the operation, and the args are the arguments for that operation. The logger format will prepend the current offset from the beginning of the simulation in milliseconds.

    Author:
    John Collins
    • Constructor Detail

      • LogService

        public LogService()
    • Method Detail

      • setPrefix

        public void setPrefix​(String prefix)
        Sets the filename prefix. This should be set to the hostname or some other distinguishing value.
      • getPrefix

        public String getPrefix()
      • getStateLogger

        public org.apache.logging.log4j.Logger getStateLogger()
      • startLog

        public void startLog()
      • startLog

        public void startLog​(String id)
      • stopLog

        public void stopLog()