Class AppLog


  • public final class AppLog
    extends java.lang.Object
    Logger in console, file and/or m_log table
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static boolean EXPLAIN_PLAN  
    • Constructor Summary

      Constructors 
      Constructor Description
      AppLog()  
    • Method Summary

      Modifier and Type Method Description
      static void clearAllLogs​(java.lang.String platform)
      Clean all logs
      static void clearLogs​(java.lang.String code, java.lang.String platform)
      Clean logs
      static java.lang.String debug​(java.lang.Class<?> className, java.lang.String method, java.lang.String str)
      Debug log (generic event DEBUG)
      static java.lang.String debug​(java.lang.Class<?> className, java.lang.String method, java.lang.String str, Grant g)
      Debug log (generic event DEBUG)
      static java.lang.String deprecation​(java.lang.Class<?> className, java.lang.String oldmethod, java.lang.String newmethod, boolean outdated)
      Deprecation warning
      static java.lang.String error​(java.lang.Class<?> className, java.lang.String method, java.lang.String str, java.lang.Throwable e, Grant g)
      Error log (generic event ERROR)
      static java.lang.String fatal​(java.lang.Class<?> className, java.lang.String method, java.lang.String str, java.lang.Throwable e, Grant g)
      Fatal log (generic event FATAL)
      static java.lang.String format​(char level, long lineNumber, java.lang.String log)
      Log line formatter with datetime, level and message
      Sample: 2010-03-12 10:25:06,703 ERROR [/<contextroot>] line 234: log message
      static java.lang.String format​(java.lang.String eventCode, java.lang.String object, java.lang.String method, java.lang.String rowId, java.lang.String desc, Grant g)  
      static java.lang.String formatAsJSON​(java.lang.String level, java.lang.String eventCode, java.lang.String object, java.lang.String method, java.lang.String rowId, java.lang.String desc, Grant g, boolean limitSize)  
      static java.text.SimpleDateFormat getDatetimeFormat()
      Date time format for logs
      static java.lang.String getLogFileName()  
      static void globalDebug​(java.lang.String message)
      Log debug message to global logger if possible
      static void globalError​(java.lang.String message)
      Log error to global logger if possible
      static void globalLog​(java.lang.String message)
      Log to global logger if possible
      static void globalLog​(java.lang.String message, java.lang.Throwable throwable)
      Log to global logger if possible
      static void globalWarning​(java.lang.String message)
      Log warning to global logger if possible
      static java.lang.String info​(java.lang.Class<?> className, java.lang.String method, java.lang.String str, Grant g)
      Info log (generic event INFO)
      static boolean isDebug()
      Is in global debug mode?
      static boolean isEventCodeEnabled​(Grant g, java.lang.String code)
      Check whether a log event code is enabled for user
      static java.lang.String[] listPlatforms()
      List platforms with logs
      static java.lang.String[] listPlatforms​(java.lang.String beginDate, java.lang.String endDate)
      List platforms with log
      static void log​(Grant g, java.io.PrintWriter out, java.lang.String code, long lineNumber, java.lang.String message)
      Log message for specified event code to print writer
      static java.lang.String log​(java.lang.String code, java.lang.Class<?> className, java.lang.String method)
      Log a code event
      static java.lang.String log​(java.lang.String code, java.lang.Class<?> className, java.lang.String method, Grant g)
      Log a code event
      static java.lang.String log​(java.lang.String code, java.lang.Class<?> className, java.lang.String method, java.lang.String param)
      Log a code event
      static java.lang.String log​(java.lang.String code, java.lang.Class<?> className, java.lang.String method, java.lang.String[] param)
      Log a code event
      static java.lang.String log​(java.lang.String code, java.lang.Class<?> className, java.lang.String method, java.lang.String[] param, Grant g)
      Log a code event
      static java.lang.String log​(java.lang.String code, java.lang.Class<?> className, java.lang.String method, java.lang.String[] param, java.lang.Throwable e)
      Log a code event
      static java.lang.String log​(java.lang.String code, java.lang.Class<?> className, java.lang.String method, java.lang.String[] param, java.lang.Throwable e, Grant g)
      Log a code event
      static java.lang.String log​(java.lang.String code, java.lang.Class<?> className, java.lang.String method, java.lang.String param, Grant g)
      Log a code event
      static java.lang.String log​(java.lang.String code, java.lang.Class<?> className, java.lang.String method, java.lang.String rowId, java.lang.String[] param, java.lang.Throwable e, Grant g)
      Log a code event
      static java.lang.String log​(java.lang.String code, java.lang.Class<?> className, java.lang.String method, java.lang.String param, java.lang.Throwable e)
      Log a code event
      static java.lang.String log​(java.lang.String code, java.lang.Class<?> className, java.lang.String method, java.lang.String param, java.lang.Throwable e, Grant g)
      Log a code event
      static java.lang.String log​(java.lang.String code, java.lang.String object, java.lang.String method, java.lang.String rowId, java.lang.String[] param, java.lang.Throwable e, Grant g)
      Log a code event
      static void logDocumentDelete​(Grant g, java.lang.String path)
      Log a document deletion
      static void logDocumentDownload​(Grant g, java.lang.String path, long size)
      Log a document download
      static void logDocumentUpload​(Grant g, java.lang.String path, long size)
      Log a document upload
      static java.lang.String logMemory()
      Log JVM memory
      static java.lang.String logMemoryCache()
      Log Cache memory
      static java.lang.String logMemoryDisk()
      Log Local disk sizes
      static java.lang.String logMemoryDoc()
      Log DBDoc sizes
      static java.lang.String logMemorySession()
      Log sessions volumes
      static void logObject​(Grant g, ObjectDB object, java.lang.String method, java.lang.String rowId, java.lang.String sql, java.util.List<ObjectField> host, java.lang.String msg)
      Log an object manipulation
      static void logSessionIn​(Grant g, java.lang.String type)
      Log the SESSION event (login)
      static void logSessionOut​(Grant g, long dt)
      Log the SESSION event (logout)
      static java.lang.String logSQL()
      Log SQL count and total duration
      static void logSQL​(java.lang.String login, java.lang.String datasource, java.lang.String sql, java.util.List<ObjectField> host)
      Log a SQL request
      static java.lang.String logSystem()
      Log Class count, Threads CPU, Snapshot and pages
      static java.lang.String readLogContent()  
      static java.lang.String warning​(java.lang.Class<?> className, java.lang.String method, java.lang.String str, java.lang.Throwable e, Grant g)
      Warning log (generic event WARN)
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AppLog

        public AppLog()
    • Method Detail

      • getLogFileName

        public static java.lang.String getLogFileName()
      • readLogContent

        public static java.lang.String readLogContent()
      • globalLog

        public static void globalLog​(java.lang.String message)
        Log to global logger if possible
        Parameters:
        message - Message to log
      • globalLog

        public static void globalLog​(java.lang.String message,
                                     java.lang.Throwable throwable)
        Log to global logger if possible
        Parameters:
        message - Message
        throwable - Throwable
      • globalDebug

        public static void globalDebug​(java.lang.String message)
        Log debug message to global logger if possible
        Parameters:
        message - Debug message to log
      • globalError

        public static void globalError​(java.lang.String message)
        Log error to global logger if possible
        Parameters:
        message - Error message to log
      • globalWarning

        public static void globalWarning​(java.lang.String message)
        Log warning to global logger if possible
        Parameters:
        message - Error message to log
      • log

        public static java.lang.String log​(java.lang.String code,
                                           java.lang.Class<?> className,
                                           java.lang.String method,
                                           java.lang.String rowId,
                                           java.lang.String[] param,
                                           java.lang.Throwable e,
                                           Grant g)
        Log a code event
        Parameters:
        code - Event code
        className - Class
        method - Method name
        rowId - Optional row_id
        param - Optional parameters to replace in text [n]
        e - Optional Java Exception
        g - Grant
        Returns:
        log Id
      • log

        public static java.lang.String log​(java.lang.String code,
                                           java.lang.Class<?> className,
                                           java.lang.String method,
                                           java.lang.String[] param,
                                           java.lang.Throwable e,
                                           Grant g)
        Log a code event
        Parameters:
        code - Event code
        className - Class
        method - Method name
        param - Optional parameters to replace in text [n]
        e - Optional Java Exception
        g - Grant
        Returns:
        log Id
      • log

        public static java.lang.String log​(java.lang.String code,
                                           java.lang.String object,
                                           java.lang.String method,
                                           java.lang.String rowId,
                                           java.lang.String[] param,
                                           java.lang.Throwable e,
                                           Grant g)
        Log a code event
        Parameters:
        code - Event code
        object - Object name
        method - Method name
        rowId - Optional row_id
        param - Optional parameters to replace in text [n]
        e - Optional Java Exception
        g - Grant
        Returns:
        log Id
      • log

        public static java.lang.String log​(java.lang.String code,
                                           java.lang.Class<?> className,
                                           java.lang.String method,
                                           java.lang.String[] param,
                                           Grant g)
        Log a code event
        Parameters:
        code - Event code
        className - Class
        method - Method name
        param - Optional parameters to replace in text [n]
        g - Grant
        Returns:
        log Id
      • log

        public static java.lang.String log​(java.lang.String code,
                                           java.lang.Class<?> className,
                                           java.lang.String method,
                                           java.lang.String[] param,
                                           java.lang.Throwable e)
        Log a code event
        Parameters:
        code - Event code
        className - Class
        method - Method name
        param - Optional parameters to replace in text [n]
        e - Optional Java Exception
        Returns:
        log Id
      • log

        public static java.lang.String log​(java.lang.String code,
                                           java.lang.Class<?> className,
                                           java.lang.String method,
                                           java.lang.String[] param)
        Log a code event
        Parameters:
        code - Event code
        className - Class
        method - Method name
        param - Optional parameters to replace in text [n]
        Returns:
        log Id
      • log

        public static java.lang.String log​(java.lang.String code,
                                           java.lang.Class<?> className,
                                           java.lang.String method)
        Log a code event
        Parameters:
        code - Event code
        className - Class
        method - Method name
        Returns:
        log Id
      • log

        public static java.lang.String log​(java.lang.String code,
                                           java.lang.Class<?> className,
                                           java.lang.String method,
                                           Grant g)
        Log a code event
        Parameters:
        code - Event code
        className - Class
        method - Method name
        g - Grant
        Returns:
        log Id
      • log

        public static java.lang.String log​(java.lang.String code,
                                           java.lang.Class<?> className,
                                           java.lang.String method,
                                           java.lang.String param)
        Log a code event
        Parameters:
        code - Event code
        className - Class
        method - Method name
        param - Optional parameter to replace in text [1]
        Returns:
        log Id
      • log

        public static java.lang.String log​(java.lang.String code,
                                           java.lang.Class<?> className,
                                           java.lang.String method,
                                           java.lang.String param,
                                           java.lang.Throwable e)
        Log a code event
        Parameters:
        code - Event code
        className - Class
        method - Method name
        param - Optional parameter to replace in text [1]
        e - Optional Java Exception
        Returns:
        log Id
      • log

        public static java.lang.String log​(java.lang.String code,
                                           java.lang.Class<?> className,
                                           java.lang.String method,
                                           java.lang.String param,
                                           Grant g)
        Log a code event
        Parameters:
        code - Event code
        className - Class
        method - Method name
        param - Optional parameter to replace in text [1]
        g - Grant
        Returns:
        log Id
      • log

        public static java.lang.String log​(java.lang.String code,
                                           java.lang.Class<?> className,
                                           java.lang.String method,
                                           java.lang.String param,
                                           java.lang.Throwable e,
                                           Grant g)
        Log a code event
        Parameters:
        code - Event code
        className - Class
        method - Method name
        param - Optional parameter to replace in text [1]
        e - Optional Java Exception
        g - Grant
        Returns:
        log Id
      • debug

        public static java.lang.String debug​(java.lang.Class<?> className,
                                             java.lang.String method,
                                             java.lang.String str)
        Debug log (generic event DEBUG)
        Parameters:
        className - Class
        method - Method name
        str - Message
        Returns:
        log Id
      • debug

        public static java.lang.String debug​(java.lang.Class<?> className,
                                             java.lang.String method,
                                             java.lang.String str,
                                             Grant g)
        Debug log (generic event DEBUG)
        Parameters:
        className - Class
        method - Method name
        str - Message
        g - Grant
        Returns:
        log Id
      • info

        public static java.lang.String info​(java.lang.Class<?> className,
                                            java.lang.String method,
                                            java.lang.String str,
                                            Grant g)
        Info log (generic event INFO)
        Parameters:
        className - Class
        method - Method name
        str - Message
        g - Grant
        Returns:
        log Id
      • warning

        public static java.lang.String warning​(java.lang.Class<?> className,
                                               java.lang.String method,
                                               java.lang.String str,
                                               java.lang.Throwable e,
                                               Grant g)
        Warning log (generic event WARN)
        Parameters:
        className - Class
        method - Method name
        str - Message
        e - Exception
        g - Grant
        Returns:
        log Id
      • error

        public static java.lang.String error​(java.lang.Class<?> className,
                                             java.lang.String method,
                                             java.lang.String str,
                                             java.lang.Throwable e,
                                             Grant g)
        Error log (generic event ERROR)
        Parameters:
        className - Class
        method - Method name
        str - Message
        e - Exception
        g - Grant
        Returns:
        log Id
      • fatal

        public static java.lang.String fatal​(java.lang.Class<?> className,
                                             java.lang.String method,
                                             java.lang.String str,
                                             java.lang.Throwable e,
                                             Grant g)
        Fatal log (generic event FATAL)
        Parameters:
        className - Class
        method - Method name
        str - Message
        e - Exception
        g - Grant
        Returns:
        log Id
      • deprecation

        public static java.lang.String deprecation​(java.lang.Class<?> className,
                                                   java.lang.String oldmethod,
                                                   java.lang.String newmethod,
                                                   boolean outdated)
        Deprecation warning
        Parameters:
        className - Class
        oldmethod - Old deprecated method
        newmethod - New method
        outdated - Outdated method (does not do anything anymore) ? Generates an error instead of a warning
        Returns:
        Deprecation warning
      • isDebug

        public static boolean isDebug()
        Is in global debug mode?
      • logSessionIn

        public static void logSessionIn​(Grant g,
                                        java.lang.String type)
        Log the SESSION event (login)
        Parameters:
        g - Grant
        type - Interface type
      • logSessionOut

        public static void logSessionOut​(Grant g,
                                         long dt)
        Log the SESSION event (logout)
        Parameters:
        g - Grant
        dt - Session duration in seconds
      • logDocumentUpload

        public static void logDocumentUpload​(Grant g,
                                             java.lang.String path,
                                             long size)
        Log a document upload
        Parameters:
        g - Grant
        path - File path
        size - File size
      • logDocumentDownload

        public static void logDocumentDownload​(Grant g,
                                               java.lang.String path,
                                               long size)
        Log a document download
        Parameters:
        g - Grant
        path - File path
        size - File size
      • logDocumentDelete

        public static void logDocumentDelete​(Grant g,
                                             java.lang.String path)
        Log a document deletion
        Parameters:
        g - Grant
        path - File path
      • logObject

        public static void logObject​(Grant g,
                                     ObjectDB object,
                                     java.lang.String method,
                                     java.lang.String rowId,
                                     java.lang.String sql,
                                     java.util.List<ObjectField> host,
                                     java.lang.String msg)
        Log an object manipulation
        Parameters:
        g - Grant
        object - Object
        method - Method name
        rowId - Record row_id
        sql - SQL statement
        host - Host values
        msg - Message
      • logSQL

        public static void logSQL​(java.lang.String login,
                                  java.lang.String datasource,
                                  java.lang.String sql,
                                  java.util.List<ObjectField> host)
        Log a SQL request
        Parameters:
        login - User (business request) or null (core system request)
        datasource - DataSource name
        sql - SQL statement
        host - Host values
      • format

        public static java.lang.String format​(java.lang.String eventCode,
                                              java.lang.String object,
                                              java.lang.String method,
                                              java.lang.String rowId,
                                              java.lang.String desc,
                                              Grant g)
      • formatAsJSON

        public static java.lang.String formatAsJSON​(java.lang.String level,
                                                    java.lang.String eventCode,
                                                    java.lang.String object,
                                                    java.lang.String method,
                                                    java.lang.String rowId,
                                                    java.lang.String desc,
                                                    Grant g,
                                                    boolean limitSize)
      • isEventCodeEnabled

        public static boolean isEventCodeEnabled​(Grant g,
                                                 java.lang.String code)
        Check whether a log event code is enabled for user
        Parameters:
        g - Grant
        code - Event code
      • log

        public static void log​(Grant g,
                               java.io.PrintWriter out,
                               java.lang.String code,
                               long lineNumber,
                               java.lang.String message)
        Log message for specified event code to print writer
        Parameters:
        g -
        out - Print writer
        code - Event code
        lineNumber - Line number
        message - Log message
      • getDatetimeFormat

        public static java.text.SimpleDateFormat getDatetimeFormat()
        Date time format for logs
        Returns:
        Date time format for logs
      • format

        public static java.lang.String format​(char level,
                                              long lineNumber,
                                              java.lang.String log)
        Log line formatter with datetime, level and message
        Sample: 2010-03-12 10:25:06,703 ERROR [/<contextroot>] line 234: log message
        Parameters:
        level - Trace level from AppLogEvent
        lineNumber - Optional line number (for adapters)
        log - Message
        Returns:
        Formatted log
      • logMemory

        public static java.lang.String logMemory()
        Log JVM memory
        Returns:
        Log JVM memory
      • logMemoryCache

        public static java.lang.String logMemoryCache()
        Log Cache memory
        Returns:
        Log Cache memory
      • logMemoryDisk

        public static java.lang.String logMemoryDisk()
        Log Local disk sizes
        Returns:
        Log Local disk sizes
      • logMemoryDoc

        public static java.lang.String logMemoryDoc()
        Log DBDoc sizes
        Returns:
        Log DBDoc sizes
      • logMemorySession

        public static java.lang.String logMemorySession()
        Log sessions volumes
        Returns:
        Log sessions volumes
      • logSystem

        public static java.lang.String logSystem()
        Log Class count, Threads CPU, Snapshot and pages
        Returns:
        Log System
      • logSQL

        public static java.lang.String logSQL()
        Log SQL count and total duration
        Returns:
        Log SQL
      • clearLogs

        public static void clearLogs​(java.lang.String code,
                                     java.lang.String platform)
        Clean logs
        Parameters:
        code - Event code
        platform - optional platform
      • clearAllLogs

        public static void clearAllLogs​(java.lang.String platform)
        Clean all logs
        Parameters:
        platform - optional platform
      • listPlatforms

        public static java.lang.String[] listPlatforms()
        List platforms with logs
        Returns:
        list platforms
      • listPlatforms

        public static java.lang.String[] listPlatforms​(java.lang.String beginDate,
                                                       java.lang.String endDate)
        List platforms with log
        Parameters:
        beginDate - begin Date
        endDate - end Date
        Returns:
        list platforms