diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2019-12-06 21:47:40 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-12-06 21:47:40 +0000 |
commit | 2986d9e70e3f23effcba1e1be0533bd84a9d1baa (patch) | |
tree | 357d533e55d00b32fb5993d0fae02024c3e0f4d0 | |
parent | e20940fdf3b8dc3016c3ca1c137285c8c6904052 (diff) | |
parent | 3073f50c525e47b0f0c4343330a9456faabeae78 (diff) |
Merge "Minor changes for new Eclipse checkstyle checks"
14 files changed, 960 insertions, 596 deletions
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java b/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java index dddd3c4d..6c0879ea 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java @@ -24,7 +24,9 @@ import javax.servlet.http.HttpServletRequest; public class OnapLoggingUtils { - private OnapLoggingUtils() {} + private OnapLoggingUtils() { + // Private constructor to prevent subclassing + } /** * Get the ONAPLoggingContext for a request. @@ -34,7 +36,7 @@ public class OnapLoggingUtils { * @return the ONAPLoggingContext */ public static OnapLoggingContext getLoggingContextForRequest(HttpServletRequest request, - OnapLoggingContext baseContext) { + OnapLoggingContext baseContext) { OnapLoggingContext requestContext = new OnapLoggingContext(baseContext); if (request.getLocalAddr() != null) { // may be null in junit tests requestContext.setServerIpAddress(request.getLocalAddr()); @@ -58,5 +60,4 @@ public class OnapLoggingUtils { return requestContext; } - } diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/ErrorCodeMap.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/ErrorCodeMap.java index 4ae4068c..fab0415b 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/ErrorCodeMap.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/ErrorCodeMap.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,56 +29,50 @@ public class ErrorCodeMap { private static final EnumMap<MessageCodes, ErrorCodeInfo> hm = new EnumMap<>(MessageCodes.class); + private static final String CHECK_ERROR_MESSAGE = " Please check the error message for detail information"; + private static final String ERROR_PERMISSIONS = "POLICY-100E"; - private static final String ERROR_PERMISSIONS_DESCRIPTION = - "This is a Permissions Error. Please check the error message for detail information"; + private static final String ERROR_PERMISSIONS_DESCRIPTION = "This is a Permissions Error." + CHECK_ERROR_MESSAGE; private static final String ERROR_SCHEMA_INVALID = "POLICY-400E"; - private static final String ERROR_SCHEMA_INVALID_DESCRIPTION = - "This is an Invalid Schema Error. Please check the error message for detail information"; + private static final String ERROR_SCHEMA_INVALID_DESCRIPTION = "This is an Invalid Schema Error." + + CHECK_ERROR_MESSAGE; private static final String UPDATE_ERROR = "POLICY-502E"; - private static final String UPDATE_ERROR_DESCRIPTION = - "This is an updating error. Please check the error message for detail information"; + private static final String UPDATE_ERROR_DESCRIPTION = "This is an updating error." + CHECK_ERROR_MESSAGE; private static final String EXCEPTION_ERROR_CODE = "POLICY-503E"; - private static final String EXCEPTION_ERROR_DESCRIPTION = - "This is an exception error message during the process. Please check the error message for detail " - + "information"; + private static final String EXCEPTION_ERROR_DESCRIPTION = "This is an exception error message during the process." + + CHECK_ERROR_MESSAGE; private static final String MISS_PROPERTY_ERROR = "POLICY-504E"; - private static final String MISS_PROPERTY_ERROR_DESCRIPTION = - "This is an error of missing properties. Please check the error message for detail information"; + private static final String MISS_PROPERTY_ERROR_DESCRIPTION = "This is an error of missing properties." + + CHECK_ERROR_MESSAGE; private static final String GENERAL_ERROR_CODE = "POLICY-515E"; - private static final String GENERAL_ERROR_DESCRIPTION = - "This is a general error message during the process. Please check the error message for detail information"; + private static final String GENERAL_ERROR_DESCRIPTION = "This is a general error message during the process." + + CHECK_ERROR_MESSAGE; private static final String ERROR_SYSTEM_ERROR = "POLICY-516E"; - private static final String ERROR_SYSTEM_ERROR_DESCRIPTION = - "This is a System Error. Please check the error message for detail information"; + private static final String ERROR_SYSTEM_ERROR_DESCRIPTION = "This is a System Error." + CHECK_ERROR_MESSAGE; private static final String ERROR_DATA_ISSUE = "POLICY-517E"; - private static final String ERROR_DATA_ISSUE_DESCRIPTION = - "This is a Data Issue Error. Please check the error message for detail information"; + private static final String ERROR_DATA_ISSUE_DESCRIPTION = "This is a Data Issue Error." + CHECK_ERROR_MESSAGE; private static final String ERROR_PROCESS_FLOW = "POLICY-518E"; - private static final String ERROR_PROCESS_FLOW_DESCRIPTION = - "This is a Process Flow Error. Please check the error message for detail information"; + private static final String ERROR_PROCESS_FLOW_DESCRIPTION = "This is a Process Flow Error." + CHECK_ERROR_MESSAGE; private static final String ERROR_UNKNOWN = "POLICY-519E"; - private static final String ERROR_UNKNOWN_DESCRIPTION = - "This is an Unknown Error. Please check the error message for detail information"; + private static final String ERROR_UNKNOWN_DESCRIPTION = "This is an Unknown Error." + CHECK_ERROR_MESSAGE; private static final String ERROR_AUDIT = "POLICY-520E"; - private static final String ERROR_AUDIT_DESCRIPTION = - "This is an audit Error. Please check the error message for detail information"; + private static final String ERROR_AUDIT_DESCRIPTION = "This is an audit Error." + CHECK_ERROR_MESSAGE; static { hm.put(MessageCodes.EXCEPTION_ERROR, new ErrorCodeInfo(EXCEPTION_ERROR_CODE, EXCEPTION_ERROR_DESCRIPTION)); hm.put(MessageCodes.GENERAL_ERROR, new ErrorCodeInfo(GENERAL_ERROR_CODE, GENERAL_ERROR_DESCRIPTION)); hm.put(MessageCodes.MISS_PROPERTY_ERROR, - new ErrorCodeInfo(MISS_PROPERTY_ERROR, MISS_PROPERTY_ERROR_DESCRIPTION)); + new ErrorCodeInfo(MISS_PROPERTY_ERROR, MISS_PROPERTY_ERROR_DESCRIPTION)); hm.put(MessageCodes.UPDATE_ERROR, new ErrorCodeInfo(UPDATE_ERROR, UPDATE_ERROR_DESCRIPTION)); hm.put(MessageCodes.ERROR_SYSTEM_ERROR, new ErrorCodeInfo(ERROR_SYSTEM_ERROR, ERROR_SYSTEM_ERROR_DESCRIPTION)); hm.put(MessageCodes.ERROR_DATA_ISSUE, new ErrorCodeInfo(ERROR_DATA_ISSUE, ERROR_DATA_ISSUE_DESCRIPTION)); @@ -86,12 +80,14 @@ public class ErrorCodeMap { hm.put(MessageCodes.ERROR_DATA_ISSUE, new ErrorCodeInfo(ERROR_DATA_ISSUE, ERROR_DATA_ISSUE_DESCRIPTION)); hm.put(MessageCodes.ERROR_PROCESS_FLOW, new ErrorCodeInfo(ERROR_PROCESS_FLOW, ERROR_PROCESS_FLOW_DESCRIPTION)); hm.put(MessageCodes.ERROR_SCHEMA_INVALID, - new ErrorCodeInfo(ERROR_SCHEMA_INVALID, ERROR_SCHEMA_INVALID_DESCRIPTION)); + new ErrorCodeInfo(ERROR_SCHEMA_INVALID, ERROR_SCHEMA_INVALID_DESCRIPTION)); hm.put(MessageCodes.ERROR_UNKNOWN, new ErrorCodeInfo(ERROR_UNKNOWN, ERROR_UNKNOWN_DESCRIPTION)); hm.put(MessageCodes.ERROR_AUDIT, new ErrorCodeInfo(ERROR_AUDIT, ERROR_AUDIT_DESCRIPTION)); } - private ErrorCodeMap() {} + private ErrorCodeMap() { + // Private constructor to prevent subclassing + } public static ErrorCodeInfo getErrorCodeInfo(MessageCodes messageCode) { return hm.get(messageCode); diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/impl/Slf4jLoggingContext.java b/common-logging/src/main/java/org/onap/policy/common/logging/nsa/impl/Slf4jLoggingContext.java index 80bb2383..33e9f637 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/impl/Slf4jLoggingContext.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/nsa/impl/Slf4jLoggingContext.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,7 +28,9 @@ import org.slf4j.MDC; * */ public class Slf4jLoggingContext implements LoggingContext { - public Slf4jLoggingContext(LoggingContext base) {} + public Slf4jLoggingContext(LoggingContext base) { + // Default constructor + } @Override public void put(String key, String value) { diff --git a/common-logging/src/main/resources/org/onap/policy/common/logging/eelf/Resources.properties b/common-logging/src/main/resources/org/onap/policy/common/logging/eelf/Resources.properties index 47480d01..4f2c3f6d 100644 --- a/common-logging/src/main/resources/org/onap/policy/common/logging/eelf/Resources.properties +++ b/common-logging/src/main/resources/org/onap/policy/common/logging/eelf/Resources.properties @@ -7,9 +7,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -56,138 +56,139 @@ GENERAL_WARNING=\ POLICY-501W|\ WARNING: {0}|\ Please check other logs for more information|\ - General warning + General warning UPDATE_ERROR=\ POLICY-502E|\ ERROR: Could not update {0}|\ Please check other logs for more information|\ - Exception caught during server management - + Exception caught during server management + EXCEPTION_ERROR=\ POLICY-503E|\ ERROR: Error Message: {0}|\ Please check other logs for more information|\ Exception caught during server management - + MISS_PROPERTY_ERROR=\ POLICY-504E|\ ERROR: {0} property not set in {1}.properties|\ Please check other logs for more information|\ - Exception caught during server management - + Exception caught during server management + BAD_TYPE_WARNING=\ POLICY-505W|\ WARNING: Bad types for Double Metric: {0} path: {1}|\ Please check other logs for more information|\ - General warning - + General warning + MISS_PROPERTY_INFO=\ POLICY-506I|\ INFO: report: {0} not set|\ No resolution needed|\ General flow processing info - + RULE_AUDIT_EXEC_INFO=\ POLICY-507I|\ Service Name: {0}:Executing rule: {1}|\ No resolution needed|\ - Executing method + Executing method RULE_AUDIT_BEGIN_INFO=\ POLICY-508I|\ Service Name: {0}:Entering rule: {1}|\ No resolution needed|\ Entering method - + RULE_AUDIT_END_INFO=\ POLICY-509I|\ Service Name: {0}:Exiting rule: {1}|\ No resolution needed|\ - Exiting method - + Exiting method + RULE_METRICS_INFO=\ POLICY-510I|\ Service Name: {0}:Executing method: {1}|\ No resolution needed|\ - Generate information for Metric events + Generate information for Metric events UEB_AUDIT_EXEC_INFO=\ POLICY-511I|\ Service Name: {0}:Executing UEB: {1}|\ No resolution needed|\ - Executing method + Executing method UEB_AUDIT_BEGIN_INFO=\ POLICY-512I|\ Service Name: {0}:Entering UEB: {1}|\ No resolution needed|\ Entering method - + UEB_AUDIT_END_INFO=\ POLICY-513I|\ Service Name: {0}:Exiting UEB: {1}|\ No resolution needed|\ - Exiting method - - - + Exiting method + + + RULE_AUDIT_START_END_INFO=\ POLICY-514I|\ - Service Name: {0}:Executing rule:{1}:Starting Time:{2}:Ending Time:{3}:Executing Time:{4}:Policy version:{5}|\ + Service Name: \ + {0}:Executing rule:{1}:Starting Time:{2}:Ending Time:{3}:Executing Time:{4}:Policy version:{5}|\ No resolution needed|\ - Executing method - + Executing method + GENERAL_ERROR=\ POLICY-515E|\ ERROR: {0}|\ Please check other logs for more information|\ - error caught during server management - + error caught during server management + ERROR_SYSTEM_ERROR=\ POLICY-516E|\ ERROR: {0}|\ Please check other logs for more information|\ - error caught during server management - + error caught during server management + ERROR_DATA_ISSUE=\ POLICY-517E|\ ERROR: {0}|\ Please check other logs for more information|\ - error caught during server management - + error caught during server management + ERROR_PERMISSIONS=\ POLICY-100E|\ ERROR: {0}|\ Please check other logs for more information|\ - error caught during server management - + error caught during server management + ERROR_PROCESS_FLOW=\ POLICY-518E|\ ERROR: {0}|\ Please check other logs for more information|\ - error caught during server management - + error caught during server management + ERROR_SCHEMA_INVALID=\ POLICY-400E|\ ERROR: {0}|\ Please check other logs for more information|\ - error caught during server management - + error caught during server management + ERROR_UNKNOWN=\ POLICY-519E|\ ERROR: {0}|\ Please check other logs for more information|\ - error caught during server management - + error caught during server management + ERROR_AUDIT=\ POLICY-520E|\ ERROR: {0}|\ Please check other logs for more information|\ - error caught during audit process + error caught during audit process ######################################################################## ######################################################################## -######################################################################## +######################################################################## #---------------- The message codes below should not be used anymore since 1607 release ----------------------------- MESSAGE_SAMPLE_NOARGS=\ @@ -195,7 +196,7 @@ MESSAGE_SAMPLE_NOARGS=\ App1 message text sample1|\ App1 resolution text sample1|\ App1 description text sample1 - + MESSAGE_SAMPLE_ONEARGUMENT=\ APP3456I|\ App1 msg smpl w arg: {0}|\ @@ -206,40 +207,40 @@ AUDIT_MESSAGE_ONEARGUMENT=\ AUD0000I|\ Audit msg: {0}|\ Audit resolution text sample2|\ - Audit description text sample2 - + Audit description text sample2 + ERROR_MESSAGE_ONEARGUMENT=\ ERR0000E|\ Error msg: {0}|\ Error resolution text sample2|\ - Error description text sample2 - + Error description text sample2 + METRICS_MESSAGE_ONEARGUMENT=\ MET0000I|\ Metrics msg: {0}|\ Metrics resolution text sample2|\ - Metrics description text sample2 - + Metrics description text sample2 + DUBUG_MESSAGE_ONEARGUMENT=\ DEB0000I|\ Debug msg: {0}|\ Debug resolution text sample2|\ - Debug description text sample2 + Debug description text sample2 MESSAGE_SAMPLE_TWOARGUMENTS=\ APP4567I|\ App1 message text sample with argument {0} and {1}|\ App1 resolution text sample3|\ App1 description text sample3 - + MESSAGE_SAMPLE_EXCEPTION=\ APP6789E|\ App1 message text sample4|\ App1 resolution text sample4|\ App1 description text sample4 - + MESSAGE_SAMPLE_EXCEPTION_ONEARGUMENT=\ APP6790E|\ This is the text exception in method {0}|\ App1 resolution text sample5|\ App1 description text sample5 - + diff --git a/integrity-audit/pom.xml b/integrity-audit/pom.xml index ce463695..e1715c9d 100644 --- a/integrity-audit/pom.xml +++ b/integrity-audit/pom.xml @@ -7,9 +7,9 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,7 +18,10 @@ ============LICENSE_END========================================================= --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> @@ -45,6 +48,12 @@ <artifactId>log4j</artifactId> </dependency> <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-ext</artifactId> + <version>1.8.0-beta4</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> </dependency> @@ -124,7 +133,7 @@ </plugins> <pluginManagement> <plugins> - <!--This plugin's configuration is used to store Eclipse m2e settings + <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. --> <plugin> <groupId>org.eclipse.m2e</groupId> diff --git a/integrity-audit/src/main/resources/logback.xml b/integrity-audit/src/main/resources/logback.xml index dc495d12..040309b9 100644 --- a/integrity-audit/src/main/resources/logback.xml +++ b/integrity-audit/src/main/resources/logback.xml @@ -18,40 +18,77 @@ ============LICENSE_END========================================================= --> -<configuration scan="true" scanPeriod="3 seconds" debug="true"> +<configuration + scan="true" + scanPeriod="3 seconds" + debug="true"> <!--<jmxConfigurator /> --> <!-- directory path for all other type logs --> - <property name="logDir" value="${POLICY_LOGS}" /> + <property + name="logDir" + value="${POLICY_LOGS}" /> <!-- directory path for debugging type logs --> - <property name="debugDir" value="${POLICY_LOGS}" /> + <property + name="debugDir" + value="${POLICY_LOGS}" /> <!-- specify the component name <ONAP-component-name>::= "MSO" | "DCAE" | "ASDC " | "AAI" |"Policy" | "SDNC" | "AC" --> - <property name="componentName" value="common-modules"></property> - <property name="subComponentName" value="integrity-audit"></property> + <property + name="componentName" + value="common-modules"></property> + <property + name="subComponentName" + value="integrity-audit"></property> <!-- log file names --> - <property name="errorLogName" value="error" /> - <property name="metricsLogName" value="metrics" /> - <property name="auditLogName" value="audit" /> - <property name="debugLogName" value="debug" /> + <property + name="errorLogName" + value="error" /> + <property + name="metricsLogName" + value="metrics" /> + <property + name="auditLogName" + value="audit" /> + <property + name="debugLogName" + value="debug" /> - <property name="defaultPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX, UTC}|%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{instanceUuid}|%p|%X{severity}|%X{serverIpAddress}|%X{server}|%X{clientIpAddress}|%c||%msg%n" /> - <!-- <property name="defaultPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX, UTC}|%X{RequestId}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{Severity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n" /> --> - <property name="logDirectory" value="${logDir}/${componentName}/${subComponentName}" /> - <property name="debugLogDirectory" value="${debugDir}/${componentName}/${subComponentName}" /> + <property + name="defaultPatternTimestamp" + value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX, UTC}" /> + + <property + name="defaultPatternTarget" + value="%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{instanceUuid}" /> + + + <property + name="defaultPatternDetails" + value="%X{severity}|%X{serverIpAddress}|%X{server}|%X{clientIpAddress}" /> + + <property + name="defaultPattern" + value="${defaultPatternTimestamp}|${defaultPatternTarget}|%p|${defaultPatternDetails}|%c||%msg%n" /> + + <property + name="debugLogDirectory" + value="${debugDir}/${componentName}/${subComponentName}" /> <!-- <property name="logDirectory" value="${logDir}/${componentName}/${subComponentName}" /> <property name="debugLogDirectory" value="${debugDir}/${componentName}/${subComponentName}" /> --> <!-- example from old log4j.properties: ${catalina.base}/logs/pdp-rest.log --> <!-- Example evaluator filter applied against console appender --> - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> + <appender + name="STDOUT" + class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> <!-- ============================================================================ --> <!-- EELF Appenders --> @@ -69,137 +106,151 @@ Policy engine events from other components, or it can be eliminated to record these events as part of the application root log. --> - <appender name="EELFAudit" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logDirectory}/${auditLogName}.log</file> - <rollingPolicy - class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> - <fileNamePattern>${logDirectory}/${auditLogName}.%i.log.zip - </fileNamePattern> - <minIndex>1</minIndex> - <maxIndex>9</maxIndex> - </rollingPolicy> - <triggeringPolicy - class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> - <maxFileSize>5MB</maxFileSize> - </triggeringPolicy> - <encoder> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> - <appender name="asyncEELFAudit" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="EELFAudit" /> - </appender> - -<appender name="EELFMetrics" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logDirectory}/${metricsLogName}.log</file> - <rollingPolicy - class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> - <fileNamePattern>${logDirectory}/${metricsLogName}.%i.log.zip - </fileNamePattern> - <minIndex>1</minIndex> - <maxIndex>9</maxIndex> - </rollingPolicy> - <triggeringPolicy - class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> - <maxFileSize>5MB</maxFileSize> - </triggeringPolicy> - <encoder> - <!-- <pattern>"%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - - %msg%n"</pattern> --> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> - - - <appender name="asyncEELFMetrics" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="EELFMetrics"/> - </appender> - - <appender name="EELFError" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logDirectory}/${errorLogName}.log</file> - <rollingPolicy - class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> - <fileNamePattern>${logDirectory}/${errorLogName}.%i.log.zip - </fileNamePattern> - <minIndex>1</minIndex> - <maxIndex>9</maxIndex> - </rollingPolicy> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>ERROR</level> - </filter> - <triggeringPolicy - class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> - <maxFileSize>5MB</maxFileSize> - </triggeringPolicy> - <encoder> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> - - <appender name="asyncEELFError" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="EELFError"/> - </appender> - - <appender name="EELFDebug" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${debugLogDirectory}/${debugLogName}.log</file> - <rollingPolicy - class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> - <fileNamePattern>${debugLogDirectory}/${debugLogName}.%i.log.zip - </fileNamePattern> - <minIndex>1</minIndex> - <maxIndex>9</maxIndex> - </rollingPolicy> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>INFO</level> - </filter> - <triggeringPolicy - class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> - <maxFileSize>5MB</maxFileSize> - </triggeringPolicy> - <encoder> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> - - <appender name="asyncEELFDebug" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="EELFDebug" /> - <includeCallerData>true</includeCallerData> - </appender> + <appender + name="EELFAudit" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${auditLogName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logDirectory}/${auditLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + <appender + name="asyncEELFAudit" + class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFAudit" /> + </appender> + + <appender + name="EELFMetrics" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${metricsLogName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logDirectory}/${metricsLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + + + <appender + name="asyncEELFMetrics" + class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFMetrics" /> + </appender> + + <appender + name="EELFError" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${errorLogName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logDirectory}/${errorLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> + <level>ERROR</level> + </filter> + <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + + <appender + name="asyncEELFError" + class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFError" /> + </appender> + + <appender + name="EELFDebug" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${debugLogDirectory}/${debugLogName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${debugLogDirectory}/${debugLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> + <level>INFO</level> + </filter> + <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + + <appender + name="asyncEELFDebug" + class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFDebug" /> + <includeCallerData>true</includeCallerData> + </appender> <!-- ============================================================================ --> <!-- EELF loggers --> <!-- ============================================================================ --> - <logger name="com.att.eelf.audit" level="info" additivity="false"> - <appender-ref ref="asyncEELFAudit" /> - </logger> + <logger + name="com.att.eelf.audit" + level="info" + additivity="false"> + <appender-ref ref="asyncEELFAudit" /> + </logger> - <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <logger + name="com.att.eelf.metrics" + level="info" + additivity="false"> <appender-ref ref="asyncEELFMetrics" /> - </logger> + </logger> - <logger name="com.att.eelf.error" level="error" additivity="false"> - <appender-ref ref="asyncEELFError" /> - </logger> + <logger + name="com.att.eelf.error" + level="error" + additivity="false"> + <appender-ref ref="asyncEELFError" /> + </logger> - <logger name="com.att.eelf.debug" level="info" additivity="false"> + <logger + name="com.att.eelf.debug" + level="info" + additivity="false"> <appender-ref ref="asyncEELFDebug" /> - </logger> + </logger> <!-- <root level="INFO"> --> - <root level="INFO"> + <root level="INFO"> <appender-ref ref="asyncEELFDebug" /> <appender-ref ref="asyncEELFError" /> - </root> + </root> </configuration> diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/DefaultLoggingPatternTest.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/DefaultLoggingPatternTest.java new file mode 100644 index 00000000..959a4e7c --- /dev/null +++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/DefaultLoggingPatternTest.java @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.common.ia; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.File; +import java.io.IOException; + +import org.junit.AfterClass; +import org.junit.Test; +import org.onap.policy.common.utils.resources.TextFileUtils; +import org.slf4j.Logger; +import org.slf4j.MDC; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; + +/** + * Test the default logging pattern. + * + */ +public class DefaultLoggingPatternTest { + // XLogger for this class + private static final XLogger XLOGGER = XLoggerFactory.getXLogger(DefaultLoggingPatternTest.class); + + // Logger for this class + private static final Logger LOGGER = XLoggerFactory.getXLogger(DefaultLoggingPatternTest.class); + + /** + * Delete logging file after test. + */ + @AfterClass + public static void deleteLogFile() { + new File("testingLogs/common-modules/integrity-audit/logging-pattern-test.log").deleteOnExit(); + } + + /** + * Test XLogger output. + * + * @throws IOException on errors + */ + @Test + public void testDefaultLoggingPatternXLogger() throws IOException { + testDefaultLoggingPattern(XLOGGER, "xlogger"); + } + + /** + * Test Logger output. + * + * @throws IOException on errors + */ + @Test + public void testDefaultLoggingPatternLogger() throws IOException { + testDefaultLoggingPattern(LOGGER, "logger"); + } + + /** + * Test Logger output. + * + * @throws IOException on errors + */ + public void testDefaultLoggingPattern(final Logger logger, final String loggerString) throws IOException { + MDC.put("requestId", "TheRequestId"); + MDC.put("serviceInstanceId", "TheServiceInstanceId"); + MDC.put("serverName", "TheServerName"); + MDC.put("serviceName", "TheServiceName"); + MDC.put("instanceUuid", "TheInstanceUuid"); + MDC.put("severity", "TheSeverity"); + MDC.put("serverIpAddress", "TheServerIpAddress"); + MDC.put("server", "TheServer"); + MDC.put("clientIpAddress", "TheClientIpAddress"); + + logger.info("This is a test logging string for {}", loggerString); + + // Jump past the date, and the actual and expected logged strings should be the same + String actualLoggedString = + TextFileUtils.getTextFileAsString("testingLogs/common-modules/integrity-audit/logging-pattern-test.log") + .substring(23); + String expectedLoggedString = TextFileUtils + .getTextFileAsString("src/test/resources/" + loggerString + "-test.expectedlog").substring(23); + + assertThat(actualLoggedString).contains(expectedLoggedString); + } +} diff --git a/integrity-audit/src/test/resources/logback-test.xml b/integrity-audit/src/test/resources/logback-test.xml index f4c656c7..e3867e79 100644 --- a/integrity-audit/src/test/resources/logback-test.xml +++ b/integrity-audit/src/test/resources/logback-test.xml @@ -20,40 +20,79 @@ <!-- Controls the output of logs for JUnit tests --> -<configuration scan="false" debug="true"> +<configuration + scan="false" + debug="true"> <!--<jmxConfigurator /> --> <!-- directory path for all other type logs --> - <property name="logDir" value="testingLogs" /> + <property + name="logDir" + value="testingLogs" /> <!-- directory path for debugging type logs --> - <property name="debugDir" value="testingLogs" /> + <property + name="debugDir" + value="testingLogs" /> <!-- specify the component name <ONAP-component-name>::= "MSO" | "DCAE" | "ASDC " | "AAI" |"Policy" | "SDNC" | "AC" --> - <property name="componentName" value="common-modules"></property> - <property name="subComponentName" value="integrity-audit"></property> + <property + name="componentName" + value="common-modules"></property> + <property + name="subComponentName" + value="integrity-audit"></property> <!-- log file names --> - <property name="errorLogName" value="error" /> - <property name="metricsLogName" value="metrics" /> - <property name="auditLogName" value="audit" /> - <property name="debugLogName" value="debug" /> + <property + name="errorLogName" + value="error" /> + <property + name="metricsLogName" + value="metrics" /> + <property + name="auditLogName" + value="audit" /> + <property + name="debugLogName" + value="debug" /> - <property name="defaultPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX, UTC}|%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{instanceUuid}|%p|%X{severity}|%X{serverIpAddress}|%X{server}|%X{clientIpAddress}|%c||%msg%n" /> - <!-- <property name="defaultPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX, UTC}|%X{RequestId}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{Severity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n" /> --> - <property name="logDirectory" value="${logDir}/${componentName}/${subComponentName}" /> - <property name="debugLogDirectory" value="${debugDir}/${componentName}/${subComponentName}" /> + <property + name="defaultPatternTimestamp" + value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX, UTC}" /> + + <property + name="defaultPatternTarget" + value="%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{instanceUuid}" /> + + + <property + name="defaultPatternDetails" + value="%X{severity}|%X{serverIpAddress}|%X{server}|%X{clientIpAddress}" /> + + <property + name="defaultPattern" + value="${defaultPatternTimestamp}|${defaultPatternTarget}|%p|${defaultPatternDetails}|%c||%msg%n" /> + + <property + name="logDirectory" + value="${logDir}/${componentName}/${subComponentName}" /> + <property + name="debugLogDirectory" + value="${debugDir}/${componentName}/${subComponentName}" /> <!-- <property name="logDirectory" value="${logDir}/${componentName}/${subComponentName}" /> <property name="debugLogDirectory" value="${debugDir}/${componentName}/${subComponentName}" /> --> <!-- example from old log4j.properties: ${catalina.base}/logs/pdp-rest.log --> <!-- Example evaluator filter applied against console appender --> - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> + <appender + name="STDOUT" + class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> <!-- ============================================================================ --> <!-- EELF Appenders --> @@ -71,99 +110,149 @@ Policy engine events from other components, or it can be eliminated to record these events as part of the application root log. --> - <appender name="EELFAudit" - class="ch.qos.logback.core.FileAppender"> - <file>${logDirectory}/${auditLogName}.log</file> - <param name="Append" value="false" /> - <encoder> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> - <appender name="asyncEELFAudit" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="EELFAudit" /> - </appender> - -<appender name="EELFMetrics" - class="ch.qos.logback.core.FileAppender"> - <file>${logDirectory}/${metricsLogName}.log</file> - <param name="Append" value="false" /> - <encoder> - <!-- <pattern>"%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - - %msg%n"</pattern> --> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> - - - <appender name="asyncEELFMetrics" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="EELFMetrics"/> - </appender> - - <appender name="EELFError" - class="ch.qos.logback.core.FileAppender"> - <file>${logDirectory}/${errorLogName}.log</file> - <param name="Append" value="false" /> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>ERROR</level> - </filter> - <encoder> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> - - <appender name="asyncEELFError" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="EELFError"/> - </appender> - - <appender name="EELFDebug" - class="ch.qos.logback.core.FileAppender"> - <file>${debugLogDirectory}/${debugLogName}.log</file> - <param name="Append" value="false" /> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <!-- <level>INFO</level> --> - <level>DEBUG</level> - </filter> - <encoder> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> - - <appender name="asyncEELFDebug" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="EELFDebug" /> - <includeCallerData>true</includeCallerData> - </appender> + <appender + name="EELFAudit" + class="ch.qos.logback.core.FileAppender"> + <file>${logDirectory}/${auditLogName}.log</file> + <param + name="Append" + value="false" /> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + <appender + name="asyncEELFAudit" + class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFAudit" /> + </appender> + + <appender + name="EELFMetrics" + class="ch.qos.logback.core.FileAppender"> + <file>${logDirectory}/${metricsLogName}.log</file> + <param + name="Append" + value="false" /> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + + + <appender + name="asyncEELFMetrics" + class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFMetrics" /> + </appender> + + <appender + name="EELFError" + class="ch.qos.logback.core.FileAppender"> + <file>${logDirectory}/${errorLogName}.log</file> + <param + name="Append" + value="false" /> + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> + <level>ERROR</level> + </filter> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + + <appender + name="asyncEELFError" + class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFError" /> + </appender> + + <appender + name="EELFDebug" + class="ch.qos.logback.core.FileAppender"> + <file>${debugLogDirectory}/${debugLogName}.log</file> + <param + name="Append" + value="false" /> + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> + <level>DEBUG</level> + </filter> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + + <appender + name="asyncEELFDebug" + class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFDebug" /> + <includeCallerData>true</includeCallerData> + </appender> + + <!-- Appender for log testing --> + <appender + name="LoggingPatternTestAppender" + class="ch.qos.logback.core.FileAppender"> + <file>${logDirectory}/logging-pattern-test.log</file> + <param + name="Append" + value="false" /> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> <!-- ============================================================================ --> <!-- EELF loggers --> <!-- ============================================================================ --> - <logger name="com.att.eelf.audit" level="info" additivity="false"> - <appender-ref ref="asyncEELFAudit" /> - </logger> + <logger + name="com.att.eelf.audit" + level="info" + additivity="false"> + <appender-ref ref="asyncEELFAudit" /> + </logger> - <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <logger + name="com.att.eelf.metrics" + level="info" + additivity="false"> <appender-ref ref="asyncEELFMetrics" /> - </logger> + </logger> - <logger name="com.att.eelf.error" level="error" additivity="false"> - <appender-ref ref="asyncEELFError" /> - </logger> + <logger + name="com.att.eelf.error" + level="error" + additivity="false"> + <appender-ref ref="asyncEELFError" /> + </logger> <!-- <logger name="com.att.eelf.debug" level="info" additivity="false"> --> - <logger name="com.att.eelf.debug" level="debug" additivity="false"> + <logger + name="com.att.eelf.debug" + level="debug" + additivity="false"> <appender-ref ref="asyncEELFDebug" /> - </logger> + </logger> <!-- <root level="INFO"> --> - <root level="DEBUG"> + <root level="DEBUG"> <appender-ref ref="asyncEELFDebug" /> <appender-ref ref="asyncEELFError" /> - </root> + </root> + + <!-- Logger for default pattern test --> + <logger + name="org.onap.policy.common.ia.DefaultLoggingPatternTest" + level="trace" + additivity="false"> + <appender-ref ref="LoggingPatternTestAppender" /> + </logger> </configuration> diff --git a/integrity-audit/src/test/resources/logback.xml b/integrity-audit/src/test/resources/logback.xml index 59d66a4e..8f493cff 100644 --- a/integrity-audit/src/test/resources/logback.xml +++ b/integrity-audit/src/test/resources/logback.xml @@ -20,40 +20,80 @@ <!-- Controls the output of logs for JUnit tests --> -<configuration scan="true" scanPeriod="3 seconds" debug="true"> +<configuration + scan="true" + scanPeriod="3 seconds" + debug="true"> <!--<jmxConfigurator /> --> <!-- directory path for all other type logs --> - <property name="logDir" value="testingLogs" /> + <property + name="logDir" + value="testingLogs" /> <!-- directory path for debugging type logs --> - <property name="debugDir" value="testingLogs" /> + <property + name="debugDir" + value="testingLogs" /> <!-- specify the component name <ONAP-component-name>::= "MSO" | "DCAE" | "ASDC " | "AAI" |"Policy" | "SDNC" | "AC" --> - <property name="componentName" value="common-modules"></property> - <property name="subComponentName" value="integrity-audit"></property> + <property + name="componentName" + value="common-modules"></property> + <property + name="subComponentName" + value="integrity-audit"></property> <!-- log file names --> - <property name="errorLogName" value="error" /> - <property name="metricsLogName" value="metrics" /> - <property name="auditLogName" value="audit" /> - <property name="debugLogName" value="debug" /> + <property + name="errorLogName" + value="error" /> + <property + name="metricsLogName" + value="metrics" /> + <property + name="auditLogName" + value="audit" /> + <property + name="debugLogName" + value="debug" /> - <property name="defaultPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX, UTC}|%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{instanceUuid}|%p|%X{severity}|%X{serverIpAddress}|%X{server}|%X{clientIpAddress}|%c||%msg%n" /> - <!-- <property name="defaultPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX, UTC}|%X{RequestId}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{Severity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n" /> --> - <property name="logDirectory" value="${logDir}/${componentName}/${subComponentName}" /> - <property name="debugLogDirectory" value="${debugDir}/${componentName}/${subComponentName}" /> + <property + name="defaultPatternTimestamp" + value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX, UTC}" /> + + <property + name="defaultPatternTarget" + value="%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{instanceUuid}" /> + + + <property + name="defaultPatternDetails" + value="%X{severity}|%X{serverIpAddress}|%X{server}|%X{clientIpAddress}" /> + + <property + name="defaultPattern" + value="${defaultPatternTimestamp}|${defaultPatternTarget}|%p|${defaultPatternDetails}|%c||%msg%n" /> + + <property + name="logDirectory" + value="${logDir}/${componentName}/${subComponentName}" /> + <property + name="debugLogDirectory" + value="${debugDir}/${componentName}/${subComponentName}" /> <!-- <property name="logDirectory" value="${logDir}/${componentName}/${subComponentName}" /> <property name="debugLogDirectory" value="${debugDir}/${componentName}/${subComponentName}" /> --> <!-- example from old log4j.properties: ${catalina.base}/logs/pdp-rest.log --> <!-- Example evaluator filter applied against console appender --> - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> + <appender + name="STDOUT" + class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> <!-- ============================================================================ --> <!-- EELF Appenders --> @@ -71,139 +111,152 @@ Policy engine events from other components, or it can be eliminated to record these events as part of the application root log. --> - <appender name="EELFAudit" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logDirectory}/${auditLogName}.log</file> - <rollingPolicy - class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> - <fileNamePattern>${logDirectory}/${auditLogName}.%i.log.zip - </fileNamePattern> - <minIndex>1</minIndex> - <maxIndex>9</maxIndex> - </rollingPolicy> - <triggeringPolicy - class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> - <maxFileSize>5MB</maxFileSize> - </triggeringPolicy> - <encoder> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> - <appender name="asyncEELFAudit" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="EELFAudit" /> - </appender> - -<appender name="EELFMetrics" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logDirectory}/${metricsLogName}.log</file> - <rollingPolicy - class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> - <fileNamePattern>${logDirectory}/${metricsLogName}.%i.log.zip - </fileNamePattern> - <minIndex>1</minIndex> - <maxIndex>9</maxIndex> - </rollingPolicy> - <triggeringPolicy - class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> - <maxFileSize>5MB</maxFileSize> - </triggeringPolicy> - <encoder> - <!-- <pattern>"%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - - %msg%n"</pattern> --> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> - - - <appender name="asyncEELFMetrics" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="EELFMetrics"/> - </appender> - - <appender name="EELFError" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logDirectory}/${errorLogName}.log</file> - <rollingPolicy - class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> - <fileNamePattern>${logDirectory}/${errorLogName}.%i.log.zip - </fileNamePattern> - <minIndex>1</minIndex> - <maxIndex>9</maxIndex> - </rollingPolicy> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>ERROR</level> - </filter> - <triggeringPolicy - class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> - <maxFileSize>5MB</maxFileSize> - </triggeringPolicy> - <encoder> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> - - <appender name="asyncEELFError" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="EELFError"/> - </appender> - - <appender name="EELFDebug" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${debugLogDirectory}/${debugLogName}.log</file> - <rollingPolicy - class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> - <fileNamePattern>${debugLogDirectory}/${debugLogName}.%i.log.zip - </fileNamePattern> - <minIndex>1</minIndex> - <maxIndex>9</maxIndex> - </rollingPolicy> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <!-- <level>INFO</level> --> - <level>DEBUG</level> - </filter> - <triggeringPolicy - class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> - <maxFileSize>5MB</maxFileSize> - </triggeringPolicy> - <encoder> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> - - <appender name="asyncEELFDebug" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="EELFDebug" /> - <includeCallerData>true</includeCallerData> - </appender> + <appender + name="EELFAudit" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${auditLogName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logDirectory}/${auditLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + <appender + name="asyncEELFAudit" + class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFAudit" /> + </appender> + + <appender + name="EELFMetrics" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${metricsLogName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logDirectory}/${metricsLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + + + <appender + name="asyncEELFMetrics" + class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFMetrics" /> + </appender> + + <appender + name="EELFError" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${errorLogName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logDirectory}/${errorLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> + <level>ERROR</level> + </filter> + <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + + <appender + name="asyncEELFError" + class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFError" /> + </appender> + + <appender + name="EELFDebug" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${debugLogDirectory}/${debugLogName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${debugLogDirectory}/${debugLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> + <level>DEBUG</level> + </filter> + <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + + <appender + name="asyncEELFDebug" + class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFDebug" /> + <includeCallerData>true</includeCallerData> + </appender> <!-- ============================================================================ --> <!-- EELF loggers --> <!-- ============================================================================ --> - <logger name="com.att.eelf.audit" level="info" additivity="false"> - <appender-ref ref="asyncEELFAudit" /> - </logger> + <logger + name="com.att.eelf.audit" + level="info" + additivity="false"> + <appender-ref ref="asyncEELFAudit" /> + </logger> - <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <logger + name="com.att.eelf.metrics" + level="info" + additivity="false"> <appender-ref ref="asyncEELFMetrics" /> - </logger> + </logger> - <logger name="com.att.eelf.error" level="error" additivity="false"> - <appender-ref ref="asyncEELFError" /> - </logger> + <logger + name="com.att.eelf.error" + level="error" + additivity="false"> + <appender-ref ref="asyncEELFError" /> + </logger> <!-- <logger name="com.att.eelf.debug" level="info" additivity="false"> --> - <logger name="com.att.eelf.debug" level="debug" additivity="false"> + <logger + name="com.att.eelf.debug" + level="debug" + additivity="false"> <appender-ref ref="asyncEELFDebug" /> - </logger> + </logger> <!-- <root level="INFO"> --> - <root level="DEBUG"> + <root level="DEBUG"> <appender-ref ref="asyncEELFDebug" /> <appender-ref ref="asyncEELFError" /> - </root> + </root> </configuration> diff --git a/integrity-audit/src/test/resources/logger-test.expectedlog b/integrity-audit/src/test/resources/logger-test.expectedlog new file mode 100644 index 00000000..69df8f96 --- /dev/null +++ b/integrity-audit/src/test/resources/logger-test.expectedlog @@ -0,0 +1 @@ +2019-12-05T13:24:14.110Z|TheRequestId|TheServiceInstanceId|main|TheServerName|TheServiceName|TheInstanceUuid|INFO|TheSeverity|TheServerIpAddress|TheServer|TheClientIpAddress|org.onap.policy.common.ia.DefaultLoggingPatternTest||This is a test logging string for logger diff --git a/integrity-audit/src/test/resources/policyLogger.properties b/integrity-audit/src/test/resources/policyLogger.properties index cb5ef8d2..42cf1cfd 100644 --- a/integrity-audit/src/test/resources/policyLogger.properties +++ b/integrity-audit/src/test/resources/policyLogger.properties @@ -7,9 +7,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,10 +23,10 @@ timer.delay.time=1000 #Timer scheduleAtFixedRate period - time in milliseconds between successive task executions. check.interval= 30000 -#Longest time an event info can be stored in the concurrentHashMap for logging - in seconds. +#Longest time an event info can be stored in the concurrentHashMap for logging - in seconds. event.expired.time=86400 -#Size of the concurrentHashMap which stores the event starting time, etc - when its size reaches this limit, the Timer gets executed -#to remove all expired records from this concurrentHashMap. +#Size of the concurrentHashMap which stores the event starting time, etc - when its size reaches this limit, the Timer +# gets executed to remove all expired records from this concurrentHashMap. concurrentHashMap.limit=5000 #Size of the concurrentHashMap - when its size drops to this point, stop the Timer stop.check.point=2500 @@ -34,7 +34,8 @@ stop.check.point=2500 # set EELF for EELF logging format, set LOG4J for using log4j, set SYSTEMOUT for using system.out.println logger.type=EELF #################################### Set level for EELF or SYSTEMOUT logging ################################## -# Set level for debug file. Set DEBUG to enable .info, .warn and .debug; set INFO for enable .info and .warn; set OFF to disable all +# Set level for debug file. Set DEBUG to enable .info, .warn and .debug; set INFO for enable .info and .warn; set OFF to +# disable all debugLogger.level=DEBUG # Set level for metrics file. Set OFF to disable; set ON to enable metricsLogger.level=ON diff --git a/integrity-audit/src/test/resources/xlogger-test.expectedlog b/integrity-audit/src/test/resources/xlogger-test.expectedlog new file mode 100644 index 00000000..a9ad4992 --- /dev/null +++ b/integrity-audit/src/test/resources/xlogger-test.expectedlog @@ -0,0 +1 @@ +2019-12-05T13:24:14.110Z|TheRequestId|TheServiceInstanceId|main|TheServerName|TheServiceName|TheInstanceUuid|INFO|TheSeverity|TheServerIpAddress|TheServer|TheClientIpAddress|org.onap.policy.common.ia.DefaultLoggingPatternTest||This is a test logging string for xlogger diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java index 4cdbe6bf..87a3ff66 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -55,6 +55,7 @@ public class IntegrityMonitorProperties { public static final Boolean ALLNOTWELL = Boolean.FALSE; public static final Boolean ALLSEEMSWELL = Boolean.TRUE; - private IntegrityMonitorProperties() {} - + private IntegrityMonitorProperties() { + // Private constructor to prevent subclassing + } } diff --git a/integrity-monitor/src/main/resources/logback.xml b/integrity-monitor/src/main/resources/logback.xml index 9dcebb85..1d498631 100644 --- a/integrity-monitor/src/main/resources/logback.xml +++ b/integrity-monitor/src/main/resources/logback.xml @@ -18,40 +18,80 @@ ============LICENSE_END========================================================= --> -<configuration scan="true" scanPeriod="3 seconds" debug="true"> +<configuration + scan="true" + scanPeriod="3 seconds" + debug="true"> <!--<jmxConfigurator /> --> <!-- directory path for all other type logs --> - <property name="logDir" value="${POLICY_LOGS}" /> + <property + name="logDir" + value="${POLICY_LOGS}" /> <!-- directory path for debugging type logs --> - <property name="debugDir" value="${POLICY_LOGS}" /> + <property + name="debugDir" + value="${POLICY_LOGS}" /> <!-- specify the component name <ONAP-component-name>::= "MSO" | "DCAE" | "ASDC " | "AAI" |"Policy" | "SDNC" | "AC" --> - <property name="componentName" value="common-modules"></property> - <property name="subComponentName" value="integrity-monitor"></property> + <property + name="componentName" + value="common-modules"></property> + <property + name="subComponentName" + value="integrity-monitor"></property> <!-- log file names --> - <property name="errorLogName" value="error" /> - <property name="metricsLogName" value="metrics" /> - <property name="auditLogName" value="audit" /> - <property name="debugLogName" value="debug" /> + <property + name="errorLogName" + value="error" /> + <property + name="metricsLogName" + value="metrics" /> + <property + name="auditLogName" + value="audit" /> + <property + name="debugLogName" + value="debug" /> - <property name="defaultPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX, UTC}|%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{instanceUuid}|%p|%X{severity}|%X{serverIpAddress}|%X{server}|%X{clientIpAddress}|%c||%msg%n" /> - <!-- <property name="defaultPattern" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX, UTC}|%X{RequestId}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{Severity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n" /> --> - <property name="logDirectory" value="${logDir}/${componentName}/${subComponentName}" /> - <property name="debugLogDirectory" value="${debugDir}/${componentName}/${subComponentName}" /> + <property + name="defaultPatternTimestamp" + value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX, UTC}" /> + + <property + name="defaultPatternTarget" + value="%X{requestId}|%X{serviceInstanceId}|%t|%X{serverName}|%X{serviceName}|%X{instanceUuid}" /> + + + <property + name="defaultPatternDetails" + value="%X{severity}|%X{serverIpAddress}|%X{server}|%X{clientIpAddress}" /> + + <property + name="defaultPattern" + value="${defaultPatternTimestamp}|${defaultPatternTarget}|%p|${defaultPatternDetails}|%c||%msg%n" /> + + <property + name="logDirectory" + value="${logDir}/${componentName}/${subComponentName}" /> + <property + name="debugLogDirectory" + value="${debugDir}/${componentName}/${subComponentName}" /> <!-- <property name="logDirectory" value="${logDir}/${componentName}/${subComponentName}" /> <property name="debugLogDirectory" value="${debugDir}/${componentName}/${subComponentName}" /> --> <!-- example from old log4j.properties: ${catalina.base}/logs/pdp-rest.log --> <!-- Example evaluator filter applied against console appender --> - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> + <appender + name="STDOUT" + class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> <!-- ============================================================================ --> <!-- EELF Appenders --> @@ -69,137 +109,153 @@ Policy engine events from other components, or it can be eliminated to record these events as part of the application root log. --> - <appender name="EELFAudit" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logDirectory}/${auditLogName}.log</file> - <rollingPolicy - class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> - <fileNamePattern>${logDirectory}/${auditLogName}.%i.log.zip - </fileNamePattern> - <minIndex>1</minIndex> - <maxIndex>9</maxIndex> - </rollingPolicy> - <triggeringPolicy - class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> - <maxFileSize>5MB</maxFileSize> - </triggeringPolicy> - <encoder> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> - <appender name="asyncEELFAudit" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="EELFAudit" /> - </appender> - -<appender name="EELFMetrics" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logDirectory}/${metricsLogName}.log</file> - <rollingPolicy - class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> - <fileNamePattern>${logDirectory}/${metricsLogName}.%i.log.zip - </fileNamePattern> - <minIndex>1</minIndex> - <maxIndex>9</maxIndex> - </rollingPolicy> - <triggeringPolicy - class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> - <maxFileSize>5MB</maxFileSize> - </triggeringPolicy> - <encoder> + <appender + name="EELFAudit" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${auditLogName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logDirectory}/${auditLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + <appender + name="asyncEELFAudit" + class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFAudit" /> + </appender> + + <appender + name="EELFMetrics" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${metricsLogName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logDirectory}/${metricsLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> <!-- <pattern>"%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n"</pattern> --> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> - - - <appender name="asyncEELFMetrics" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="EELFMetrics"/> - </appender> - - <appender name="EELFError" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logDirectory}/${errorLogName}.log</file> - <rollingPolicy - class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> - <fileNamePattern>${logDirectory}/${errorLogName}.%i.log.zip - </fileNamePattern> - <minIndex>1</minIndex> - <maxIndex>9</maxIndex> - </rollingPolicy> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>ERROR</level> - </filter> - <triggeringPolicy - class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> - <maxFileSize>5MB</maxFileSize> - </triggeringPolicy> - <encoder> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> - - <appender name="asyncEELFError" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="EELFError"/> - </appender> - - <appender name="EELFDebug" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${debugLogDirectory}/${debugLogName}.log</file> - <rollingPolicy - class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> - <fileNamePattern>${debugLogDirectory}/${debugLogName}.%i.log.zip - </fileNamePattern> - <minIndex>1</minIndex> - <maxIndex>9</maxIndex> - </rollingPolicy> - <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> - <level>INFO</level> - </filter> - <triggeringPolicy - class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> - <maxFileSize>5MB</maxFileSize> - </triggeringPolicy> - <encoder> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> - - <appender name="asyncEELFDebug" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="EELFDebug" /> - <includeCallerData>true</includeCallerData> - </appender> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + + + <appender + name="asyncEELFMetrics" + class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFMetrics" /> + </appender> + + <appender + name="EELFError" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${errorLogName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${logDirectory}/${errorLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> + <level>ERROR</level> + </filter> + <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + + <appender + name="asyncEELFError" + class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFError" /> + </appender> + + <appender + name="EELFDebug" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${debugLogDirectory}/${debugLogName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> + <fileNamePattern>${debugLogDirectory}/${debugLogName}.%i.log.zip + </fileNamePattern> + <minIndex>1</minIndex> + <maxIndex>9</maxIndex> + </rollingPolicy> + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> + <level>INFO</level> + </filter> + <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> + <maxFileSize>5MB</maxFileSize> + </triggeringPolicy> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + + <appender + name="asyncEELFDebug" + class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFDebug" /> + <includeCallerData>true</includeCallerData> + </appender> <!-- ============================================================================ --> <!-- EELF loggers --> <!-- ============================================================================ --> - <logger name="com.att.eelf.audit" level="info" additivity="false"> - <appender-ref ref="asyncEELFAudit" /> - </logger> + <logger + name="com.att.eelf.audit" + level="info" + additivity="false"> + <appender-ref ref="asyncEELFAudit" /> + </logger> - <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <logger + name="com.att.eelf.metrics" + level="info" + additivity="false"> <appender-ref ref="asyncEELFMetrics" /> - </logger> + </logger> - <logger name="com.att.eelf.error" level="error" additivity="false"> - <appender-ref ref="asyncEELFError" /> - </logger> + <logger + name="com.att.eelf.error" + level="error" + additivity="false"> + <appender-ref ref="asyncEELFError" /> + </logger> - <logger name="com.att.eelf.debug" level="info" additivity="false"> + <logger + name="com.att.eelf.debug" + level="info" + additivity="false"> <appender-ref ref="asyncEELFDebug" /> - </logger> + </logger> <!-- <root level="INFO"> --> - <root level="INFO"> + <root level="INFO"> <appender-ref ref="asyncEELFDebug" /> <appender-ref ref="asyncEELFError" /> - </root> + </root> </configuration> |