Class FileTracer


  • public class FileTracer
    extends AbstractTracer
    This particular tracer logs into the local file system.
    Author:
    Christof Reichardt
    • Field Detail

      • traceLogfile

        protected File traceLogfile
        the actual log file
      • fileOutputStream

        protected FileOutputStream fileOutputStream
        the underlying OutputStream
      • byteLimit

        protected volatile long byteLimit
        indicates the lower bound of the number of bytes which leads to a log file rotation
      • logDirPath

        protected Path logDirPath
        denotes default log directory
      • counter

        protected int counter
        counts the number of file splittings
    • Constructor Detail

      • FileTracer

        public FileTracer​(String name)
        Constructor expects the preferably unique tracer name. This is at the same time the name of the logfile.
        Parameters:
        name - the name of the tracer
    • Method Detail

      • getLogDirPath

        public Path getLogDirPath()
        Gives the path to the directory of the logfile.
        Returns:
        the logDirPath
      • setLogDirPath

        public void setLogDirPath​(Path logDirPath)
        Sets the path to the directory of the logfile.
        Parameters:
        logDirPath - the logDirPath to set
      • getByteLimit

        public long getByteLimit()
        Indicates the lower bound of the number of bytes which leads to a log file rotation.
        Returns:
        the byteLimit
      • setByteLimit

        public void setByteLimit​(long byteLimit)
        Sets the lower bound of the number of bytes which leads to a log file rotation.
        Parameters:
        byteLimit - the byteLimit to set
      • open

        public void open()
        Creates the underlying trace file and opens the associated trace streams. The file name will be assembled by the path to log directory and the name of the tracer.
        Specified by:
        open in class AbstractTracer
      • close

        public void close()
        Closes the associated trace streams.
        Specified by:
        close in class AbstractTracer
      • checkLimit

        protected void checkLimit()
        Checks if the file size limit has been exceeded and splits the trace file if need be.
      • logException

        public void logException​(LogLevel logLevel,
                                 Throwable throwable,
                                 Class<?> clazz,
                                 String methodName)
        Description copied from class: AbstractTracer
        Logs an exception with the given logLevel and the originating class.
        Overrides:
        logException in class AbstractTracer
        Parameters:
        logLevel - one of the predefined levels INFO, WARNING, ERROR, FATAL and SEVERE
        throwable - the to be logged throwable
        clazz - the originating class
        methodName - the name of the relevant method
      • logMessage

        public void logMessage​(LogLevel logLevel,
                               String message,
                               Class<?> clazz,
                               String methodName)
        Description copied from class: AbstractTracer
        Logs a message with the given logLevel and the originating class.
        Overrides:
        logMessage in class AbstractTracer
        Parameters:
        logLevel - one of the predefined levels INFO, WARNING, ERROR, FATAL and SEVERE
        message - the to be logged message
        clazz - the originating class
        methodName - the originating method