Class SAPLoggingProxyListener

  • All Implemented Interfaces:
    HybrisLogListener

    public class SAPLoggingProxyListener
    extends java.lang.Object
    implements HybrisLogListener
    A listener to serve as a proxy to the SAP Logging framework (ListLog 2.0) Upon initialization, this listener registers itself with the Hybris logging framework and acts as a proxy to the SAP ListLog logging framework. Whenever a log event occurs, this framework simply passes it to the SAP's SimpleLogger interface which has builtin logic to determine whether the event should be logged or traced. This is also the reason that the isEnabledFor() always returns true because the actual determination of whether the log or trace should be written is done by the SAP logging framework internally. Important: This proxy listener will suppress any logging event which doesn't pass the Root logger's threshold level. For example, if the root logger is set to OFF, then the log/trace severities of the SAP logging framework won't matter. Here are a few example scenarios: (2) Root logger = OFF, SAP Log severity = DEBUG => No messages will be logged (2) Root logger = DEBUG, SAP Log severity = DEBUG => All messages will get logged (3) Root logger = ERROR, SAP log severity = DEBUG => Only ERROR and FATAL messages will get logged
    • Constructor Detail

      • SAPLoggingProxyListener

        public SAPLoggingProxyListener()
    • Method Detail

      • init

        public void init()
        Initializes some of the properties and registers the listener with HybrisLogger
      • register

        public void register()
        Registers this listener with HybrisLogger
      • deregister

        public void deregister()
        Deregisters the listener from HybrisLogger
      • isEnabledFor

        public boolean isEnabledFor​(org.apache.log4j.Level level)
        Decides whether the current logging event should be logged or not Always returns true because this listener is just a proxy to the SAP logging framework, it just passed the logging event to the framwork. Then, the framework has builtin logic to determine whether to log/trace the event or not.
        Specified by:
        isEnabledFor in interface HybrisLogListener
        Parameters:
        level - level of the log which has to be checked for filtering
        Returns:
        true, if level is OK and log can be passed to log method, false otherwise
      • log4jLevelToSAPSeverity

        protected int log4jLevelToSAPSeverity​(org.apache.logging.log4j.Level level)
        Maps default Log4J 2 Level to SAP Severity
        Parameters:
        level - The Log4J level
        Returns:
        mapped SAP Severity
      • log4jConvertLevel1to2

        protected org.apache.logging.log4j.Level log4jConvertLevel1to2​(org.apache.log4j.Level level)
        Converts Log4J 1 Level to Log4J 2 Level NOTE: The class HybrisLoggingEvent is still using the Log4J 1.2 Level. Therefore, this class is just there to map the old levels to new ones.
        Parameters:
        level - Level object from Log4J 1.2 package
        Returns:
        Level object from Log4J 2.5 package
      • log

        public void log​(HybrisLoggingEvent e)
        Writes the log or trace to the physical file. Collects all the information about the logging event and writes the log and trace if necessary. SAP logging api provides SimpleLogger interface to write the logs and traces to phyical files. The api internally determines when to write the log or trace based on the severities we set. This is also the reason that the isEnabledFor() method is always returning true.
        Specified by:
        log in interface HybrisLogListener
        Parameters:
        e - the log which will be processed
      • setLogFilePath

        public void setLogFilePath​(java.lang.String logFilePath)
      • setTraceFilePath

        public void setTraceFilePath​(java.lang.String traceFilePath)
      • setLogSeverity

        public void setLogSeverity​(java.lang.String logSeverity)
      • setTraceSeverity

        public void setTraceSeverity​(java.lang.String traceSeverity)
      • setRotationSize

        public void setRotationSize​(int rotationSize)
      • setRotationCount

        public void setRotationCount​(int rotationCount)
      • setCsnComponentName

        public void setCsnComponentName​(java.lang.String csnComponentName)
      • setDcComponentName

        public void setDcComponentName​(java.lang.String dcComponentName)
      • setEnableTracing

        public void setEnableTracing​(boolean enableTracing)
      • setDataSupplierRepositoryService

        public void setDataSupplierRepositoryService​(DataSupplierRepositoryService dataSupplierRepositoryService)
      • setConfigurationService

        public void setConfigurationService​(ConfigurationService configurationService)
      • getLogSeverity

        public java.lang.String getLogSeverity()
      • getTraceSeverity

        public java.lang.String getTraceSeverity()
      • isEnableTracing

        public boolean isEnableTracing()
      • getLogFilePath

        public java.lang.String getLogFilePath()
      • getTraceFilePath

        public java.lang.String getTraceFilePath()
      • getRotationCount

        public int getRotationCount()
      • getRotationSize

        public int getRotationSize()