Class TCLogStatistic


  • public class TCLogStatistic
    extends java.lang.Object
    Class for keeping up-to-date statistics from log4j appender Attention: singleton. Can be changed to a class with state
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.lang.String appenderName, LogEvent event, java.lang.String logFileName, <any> layout)
      Add event to statistics
      java.util.List<java.lang.String> getCaptureErrorMessages()
      Get last error message
      java.util.Date getLastErrorTime()
      Get last error time
      java.lang.String getLogFileName()
      Get log file name with last error
      IntervalStatistic getStatistic()
      Get actual statistic
      static TCLogStatistic init​(LogEvent event, java.lang.String appenderName, java.lang.String logFileName, TimeService timeService, java.lang.String periods)
      Create a new instance if the instance is not created or change current instance or do nothing if the log level is low or do nothing if the appender is not being tracked
      static boolean isEnabledForEvent​(LogEvent event)  
      static void remove()  
      void rollOver​(java.lang.String appenderName, java.lang.String logFileName, int backupIndex)
      Change the file name if log4j wants to rotate log files
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • init

        @Nullable
        public static TCLogStatistic init​(@NotNull
                                          LogEvent event,
                                          @Nullable
                                          java.lang.String appenderName,
                                          @Nullable
                                          java.lang.String logFileName,
                                          @NotNull
                                          TimeService timeService,
                                          @Nullable
                                          java.lang.String periods)
        Create a new instance if the instance is not created or change current instance or do nothing if the log level is low or do nothing if the appender is not being tracked
        Parameters:
        event - log event with log level
        appenderName - appender created event
        logFileName - the file contains a event
        timeService - time service, it will be used to obtain current time
        periods - observed time intervals. configuration with ";" delimiter, like "10m; 1h; 1d; 30d; 1y"
        Returns:
        new or old instance
      • isEnabledForEvent

        public static boolean isEnabledForEvent​(@NotNull
                                                LogEvent event)
      • remove

        public static void remove()
      • add

        public void add​(@Nullable
                        java.lang.String appenderName,
                        @NotNull
                        LogEvent event,
                        @NotNull
                        java.lang.String logFileName,
                        @Nullable
                        <any> layout)
        Add event to statistics
        Parameters:
        appenderName - appender created event
        event - new event
        logFileName - log file name
        layout -
      • getLogFileName

        @Nullable
        public java.lang.String getLogFileName()
        Get log file name with last error
        Returns:
        log file name with last error
      • getCaptureErrorMessages

        @Nullable
        public java.util.List<java.lang.String> getCaptureErrorMessages()
        Get last error message
        Returns:
        last error message
      • getStatistic

        @NotNull
        public IntervalStatistic getStatistic()
        Get actual statistic
        Returns:
        actual statistic
      • getLastErrorTime

        @Nullable
        public java.util.Date getLastErrorTime()
        Get last error time
        Returns:
        last error time
      • rollOver

        public void rollOver​(@Nullable
                             java.lang.String appenderName,
                             @NotNull
                             java.lang.String logFileName,
                             int backupIndex)
        Change the file name if log4j wants to rotate log files
        Parameters:
        appenderName - rotated appender
        logFileName - orig file name