|
| 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, all logging configuration settings are entrusted to the log4j2 framework. For this, a new file `log4j.xml` has to be added to contain the configuration properties. A sample file has been provided below. |
| 8 | + |
| 9 | +For more detailed information on how to change this configuration file, refer to [Apache Log4j2 Configuration](https://logging.apache.org/log4j/2.x/manual/configuration.html). |
| 10 | + |
| 11 | + |
| 12 | +## Log4j Configuration |
| 13 | + |
| 14 | +### Sample log4j.xml File |
| 15 | + |
| 16 | +```xml |
| 17 | +<?xml version="1.0" encoding="UTF-8"?> |
| 18 | + |
| 19 | +<!-- ################################################################################################################ --> |
| 20 | +<!-- For information on how to change this configuration file, --> |
| 21 | +<!-- refer to https://logging.apache.org/log4j/2.x/manual/configuration.html --> |
| 22 | + |
| 23 | +<!-- To enable masking of sensitive data, replace `%m` with `%maskedMessage` in the patterns below --> |
| 24 | +<!-- ################################################################################################################ --> |
| 25 | + |
| 26 | +<Configuration status="warn"> |
| 27 | + <Properties> |
| 28 | + <Property name="log-path">./logs</Property> |
| 29 | + <Property name="logFileName">application</Property> |
| 30 | + </Properties> |
| 31 | + <Appenders> |
| 32 | + <Console name="LogToConsole" target="SYSTEM_OUT"> |
| 33 | + <PatternLayout pattern="%d{MM/dd/yy HH:mm:ss,SS:} [%t] %5p (%C{1}:%-1L) - %m%n"/> |
| 34 | + </Console> |
| 35 | + <RollingFile name="RollingFile" |
| 36 | + fileName="${log-path}/${logFileName}.log" |
| 37 | + filePattern="${log-path}/${logFileName}-%d{yyyy-MM-dd}-%i.log"> |
| 38 | + <PatternLayout> |
| 39 | + <pattern>%d{MM/dd/yy HH:mm:ss,SS:} [%t] %5p (%C{1}:%-1L) - %m%n</pattern> |
| 40 | + </PatternLayout> |
| 41 | + <Policies> |
| 42 | + <TimeBasedTriggeringPolicy interval="1" modulate="true"/> |
| 43 | + </Policies> |
| 44 | + <DefaultRolloverStrategy max="4"/> |
| 45 | + </RollingFile> |
| 46 | + </Appenders> |
| 47 | + <Loggers> |
| 48 | + <Logger name="com.cybersource" level="error" additivity="true"> |
| 49 | + <AppenderRef ref="LogToConsole" level="error" /> |
| 50 | + </Logger> |
| 51 | + <Logger name="Api" level="error" additivity="true"> |
| 52 | + <AppenderRef ref="LogToConsole" level="error" /> |
| 53 | + </Logger> |
| 54 | + <Logger name="Invoker" level="error" additivity="true"> |
| 55 | + <AppenderRef ref="LogToConsole" level="error" /> |
| 56 | + </Logger> |
| 57 | + <Logger name="samples" level="error" additivity="true"> |
| 58 | + <AppenderRef ref="LogToConsole" level="error" /> |
| 59 | + </Logger> |
| 60 | + <Root level="info" additivity="true"> |
| 61 | + <AppenderRef ref="RollingFile" /> |
| 62 | + </Root> |
| 63 | + <Logger name="com.cybersource" level="info" additivity="true"> |
| 64 | + <AppenderRef ref="LogToConsole" level="info" /> |
| 65 | + </Logger> |
| 66 | + <Logger name="Api" level="info" additivity="true"> |
| 67 | + <AppenderRef ref="LogToConsole" level="info" /> |
| 68 | + </Logger> |
| 69 | + <Logger name="Invoker" level="info" additivity="true"> |
| 70 | + <AppenderRef ref="LogToConsole" level="info" /> |
| 71 | + </Logger> |
| 72 | + <Logger name="samples" level="info" additivity="true"> |
| 73 | + <AppenderRef ref="LogToConsole" level="info" /> |
| 74 | + </Logger> |
| 75 | + </Loggers> |
| 76 | +</Configuration> |
| 77 | +``` |
| 78 | + |
| 79 | +### Important Notes |
| 80 | +* 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 pattern below: |
| 81 | + |
| 82 | + ```xml |
| 83 | + <PatternLayout pattern="%d{MM/dd/yy HH:mm:ss,SS:} [%t] %5p (%C{1}:%-1L) - %m%n"/> |
| 84 | + ``` |
| 85 | + must be replaced with |
| 86 | + ```xml |
| 87 | + <PatternLayout pattern="%d{MM/dd/yy HH:mm:ss,SS:} [%t] %5p (%C{1}:%-1L) - %maskedMessage%n"/> |
| 88 | + ``` |
| 89 | + |
| 90 | + |
| 91 | +* Sensitive data fields are listed below: |
| 92 | + * Card Security Code |
| 93 | + * Card Number |
| 94 | + * Any field with number in the name |
| 95 | + * Card Expiration Month |
| 96 | + * Card Expiration Year |
| 97 | + * Account |
| 98 | + * Routing Number |
| 99 | + * Email |
| 100 | + * First Name & Last Name |
| 101 | + * Phone Number |
| 102 | + * Type |
| 103 | + * Token |
| 104 | + * Signature |
0 commit comments