Class SAPLoggingProxyListener
java.lang.Object
de.hybris.e2e.hybrisrootcauseanalysis.exceptionanalysis.SAPLoggingProxyListener
- All Implemented Interfaces:
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.
The isEnabledFor() is set by the enableevents property. If set to true, enables the event flow (tracing and logging). In addition the determination of whether the log or trace should be
written is done by the SAP logging framework.
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDeregisters the listener from HybrisLoggerintintvoidinit()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 By default it's set to true.booleanbooleanvoidWrites 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(String csnComponentName) voidsetDataSupplierRepositoryService(DataSupplierRepositoryService dataSupplierRepositoryService) voidsetDcComponentName(String dcComponentName) voidsetEnableEvents(boolean enableEvents) voidsetEnableTracing(boolean enableTracing) voidsetLogFilePath(String logFilePath) voidsetLogSeverity(String logSeverity) voidsetRotationCount(int rotationCount) voidsetRotationSize(int rotationSize) voidsetTraceFilePath(String traceFilePath) voidsetTraceSeverity(String traceSeverity)
-
Field Details
-
FIELD_MSG_ID
- See Also:
-
FIELD_CATEGORY
- See Also:
-
-
Constructor Details
-
SAPLoggingProxyListener
public SAPLoggingProxyListener()
-
-
Method Details
-
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 By default it's set to true. 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
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
-
setTraceFilePath
-
setLogSeverity
-
setTraceSeverity
-
setRotationSize
public void setRotationSize(int rotationSize) -
setRotationCount
public void setRotationCount(int rotationCount) -
setCsnComponentName
-
setDcComponentName
-
setEnableEvents
public void setEnableEvents(boolean enableEvents) -
setEnableTracing
public void setEnableTracing(boolean enableTracing) -
setDataSupplierRepositoryService
public void setDataSupplierRepositoryService(DataSupplierRepositoryService dataSupplierRepositoryService) -
setConfigurationService
-
getLogSeverity
-
getTraceSeverity
-
isEnableTracing
public boolean isEnableTracing() -
isEnableEvents
public boolean isEnableEvents() -
getLogFilePath
-
getTraceFilePath
-
getRotationCount
public int getRotationCount() -
getRotationSize
public int getRotationSize()
-