Class SAPLoggingProxyListener
- java.lang.Object
-
- de.hybris.e2e.hybrisrootcauseanalysis.exceptionanalysis.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
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringFIELD_CATEGORYstatic java.lang.StringFIELD_MSG_ID
-
Constructor Summary
Constructors Constructor Description SAPLoggingProxyListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidderegister()Deregisters the listener from HybrisLoggerjava.lang.StringgetLogFilePath()java.lang.StringgetLogSeverity()intgetRotationCount()intgetRotationSize()java.lang.StringgetTraceFilePath()java.lang.StringgetTraceSeverity()voidinit()Initializes some of the properties and registers the listener with HybrisLoggerbooleanisEnabledFor(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.booleanisEnableTracing()voidlog(HybrisLoggingEvent e)Writes the log or trace to the physical file.protected org.apache.logging.log4j.Levellog4jConvertLevel1to2(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.protected intlog4jLevelToSAPSeverity(org.apache.logging.log4j.Level level)Maps default Log4J 2 Level to SAP Severityvoidregister()Registers this listener with HybrisLoggervoidsetConfigurationService(ConfigurationService configurationService)voidsetCsnComponentName(java.lang.String csnComponentName)voidsetDataSupplierRepositoryService(DataSupplierRepositoryService dataSupplierRepositoryService)voidsetDcComponentName(java.lang.String dcComponentName)voidsetEnableTracing(boolean enableTracing)voidsetLogFilePath(java.lang.String logFilePath)voidsetLogSeverity(java.lang.String logSeverity)voidsetRotationCount(int rotationCount)voidsetRotationSize(int rotationSize)voidsetTraceFilePath(java.lang.String traceFilePath)voidsetTraceSeverity(java.lang.String traceSeverity)
-
-
-
Field Detail
-
FIELD_MSG_ID
public static final java.lang.String FIELD_MSG_ID
- See Also:
- Constant Field Values
-
FIELD_CATEGORY
public static final java.lang.String FIELD_CATEGORY
- See Also:
- Constant Field Values
-
-
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:
isEnabledForin interfaceHybrisLogListener- 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
logmethod, 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:
login interfaceHybrisLogListener- 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()
-
-