|
| 1 | +[](https://shields.io/) |
| 2 | + |
| 3 | +# Logging in CyberSource REST Client SDK (JAVA) |
| 4 | +Logging framework has been introduced in the SDK which makes use of log4j2 and standardizes the logging so that it can be integrated with the logging in the client application. |
| 5 | + |
| 6 | +## Setup |
| 7 | +In order to leverage the new logging framework, the following configuration settings may be added to the merchant configuration as part of LogConfiguration: |
| 8 | + |
| 9 | +enableLog |
| 10 | +logDirectory |
| 11 | +logFilename |
| 12 | +logMaximumSize |
| 13 | + |
| 14 | +have to be replaced by the following values: |
| 15 | +// Logging to be enabled or not. |
| 16 | +props.setProperty("enableLog", "true"); |
| 17 | +// Log directory Path |
| 18 | +props.setProperty("logDirectory", "logs"); |
| 19 | +props.setProperty("logFilename", "cybs"); |
| 20 | +// Log file size in KB |
| 21 | +props.setProperty("logMaximumSize", "5M"); |
| 22 | + |
| 23 | +where, enableLog, logDirectory, logFilename, logMaximumSize are variables to be provided |
| 24 | + |
| 25 | + |
| 26 | +# Log4j Configuration |
| 27 | + |
| 28 | +### Sample log4j.xml File |
| 29 | + |
| 30 | +```xml |
| 31 | +<?xml version="1.0" encoding="UTF-8"?> |
| 32 | + |
| 33 | +<!-- ################################################################################################################ --> |
| 34 | +<!-- For information on how to change this configuration file, --> |
| 35 | +<!-- refer to https://logging.apache.org/log4j/2.x/manual/configuration.html --> |
| 36 | + |
| 37 | +<!-- To enable masking of sensitive data, replace `%m` with `%maskedMessage` in the patterns below --> |
| 38 | +<!-- ################################################################################################################ --> |
| 39 | + |
| 40 | +<Configuration status="warn"> |
| 41 | + <Properties> |
| 42 | + <Property name="log-path">./logs</Property> |
| 43 | + <Property name="logFileName">application</Property> |
| 44 | + </Properties> |
| 45 | + <Appenders> |
| 46 | + <Console name="LogToConsole" target="SYSTEM_OUT"> |
| 47 | + <PatternLayout pattern="%d{MM/dd/yy HH:mm:ss,SS:} [%t] %5p (%C{1}:%-1L) - %maskedMessage%n"/> |
| 48 | + </Console> |
| 49 | + <RollingFile name="RollingFile" |
| 50 | + fileName="${log-path}/${logFileName}.log" |
| 51 | + filePattern="${log-path}/${logFileName}-%d{yyyy-MM-dd}-%i.log"> |
| 52 | + <PatternLayout> |
| 53 | + <pattern>%d{MM/dd/yy HH:mm:ss,SS:} [%t] %5p (%C{1}:%-1L) - %maskedMessage%n</pattern> |
| 54 | + </PatternLayout> |
| 55 | + <Policies> |
| 56 | + <TimeBasedTriggeringPolicy interval="1" modulate="true"/> |
| 57 | + </Policies> |
| 58 | + <DefaultRolloverStrategy max="4"/> |
| 59 | + </RollingFile> |
| 60 | + </Appenders> |
| 61 | + <Loggers> |
| 62 | + <Logger name="com.cybersource" level="error" additivity="true"> |
| 63 | + <AppenderRef ref="LogToConsole" level="error" /> |
| 64 | + </Logger> |
| 65 | + <Logger name="Api" level="error" additivity="true"> |
| 66 | + <AppenderRef ref="LogToConsole" level="error" /> |
| 67 | + </Logger> |
| 68 | + <Logger name="Invoker" level="error" additivity="true"> |
| 69 | + <AppenderRef ref="LogToConsole" level="error" /> |
| 70 | + </Logger> |
| 71 | + <Logger name="samples" level="error" additivity="true"> |
| 72 | + <AppenderRef ref="LogToConsole" level="error" /> |
| 73 | + </Logger> |
| 74 | + <Root level="info" additivity="true"> |
| 75 | + <AppenderRef ref="RollingFile" /> |
| 76 | + </Root> |
| 77 | + <Logger name="com.cybersource" level="info" additivity="true"> |
| 78 | + <AppenderRef ref="LogToConsole" level="info" /> |
| 79 | + </Logger> |
| 80 | + <Logger name="Api" level="info" additivity="true"> |
| 81 | + <AppenderRef ref="LogToConsole" level="info" /> |
| 82 | + </Logger> |
| 83 | + <Logger name="Invoker" level="info" additivity="true"> |
| 84 | + <AppenderRef ref="LogToConsole" level="info" /> |
| 85 | + </Logger> |
| 86 | + <Logger name="samples" level="info" additivity="true"> |
| 87 | + <AppenderRef ref="LogToConsole" level="info" /> |
| 88 | + </Logger> |
| 89 | + </Loggers> |
| 90 | +</Configuration> |
| 91 | +``` |
| 92 | + |
| 93 | +### Important Notes |
| 94 | +To enable masking of sensitive data i.e. sensitive data in the request/response should be hidden/masked, then replace `%m` with `%maskedMessage` in the patterns below --> |
| 95 | +<PatternLayout pattern="%d{MM/dd/yy HH:mm:ss,SS:} [%t] %5p (%C{1}:%-1L) - %m%n"/> |
| 96 | +replace with |
| 97 | +<PatternLayout pattern="%d{MM/dd/yy HH:mm:ss,SS:} [%t] %5p (%C{1}:%-1L) - %maskedMessage%n"/> |
| 98 | + |
| 99 | + |
| 100 | +* Sensitive data fields are listed below: |
| 101 | +Card Security Code |
| 102 | +Card Number |
| 103 | +Any field with number in the name |
| 104 | +Card Expiration Month |
| 105 | +Card Expiration Year |
| 106 | +Account |
| 107 | +Routing Number |
| 108 | +Email |
| 109 | +First Name & Last Name |
| 110 | +Phone Number |
| 111 | +Type |
| 112 | +Token |
| 113 | +Signature |
0 commit comments