From 499e4e89cb68c99547df5632df358847b62ccc3f Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Thu, 9 Aug 2018 17:14:09 +0200 Subject: [PATCH] Fix logback.xml location The logback.xml location was not working, it was not possible to specify an external logback.xml file. Now it works from application.properties Issue-ID: CLAMP-179 Change-Id: I87c9be70561fc0897b5c6499a431f7cd788c1867 Signed-off-by: Determe, Sebastien (sd378r) --- pom.xml | 5 + src/main/java/org/onap/clamp/clds/Application.java | 12 +- src/main/resources/application-noaaf.properties | 4 + src/main/resources/application.properties | 4 + src/main/resources/boot-message.txt | 7 + src/main/resources/logback-default.xml | 237 ++++++++++++++++++++ src/main/resources/logback.xml | 238 ++------------------- src/main/resources/system.properties | 6 - src/test/resources/application.properties | 6 +- src/test/resources/https/https-test.properties | 6 + 10 files changed, 294 insertions(+), 231 deletions(-) create mode 100644 src/main/resources/boot-message.txt create mode 100644 src/main/resources/logback-default.xml diff --git a/pom.xml b/pom.xml index b7d8fb24..026eb5cb 100644 --- a/pom.xml +++ b/pom.xml @@ -224,6 +224,11 @@ eelf-core ${eelf.core.version} + + org.codehaus.janino + janino + 3.0.8 + org.apache.tomcat.embed tomcat-embed-core diff --git a/src/main/java/org/onap/clamp/clds/Application.java b/src/main/java/org/onap/clamp/clds/Application.java index 0eb48075..749a2f6f 100644 --- a/src/main/java/org/onap/clamp/clds/Application.java +++ b/src/main/java/org/onap/clamp/clds/Application.java @@ -26,10 +26,13 @@ package org.onap.clamp.clds; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; +import java.io.IOException; + import org.apache.catalina.connector.Connector; import org.onap.clamp.clds.model.properties.Holmes; import org.onap.clamp.clds.model.properties.ModelProperties; import org.onap.clamp.clds.util.ClampVersioning; +import org.onap.clamp.clds.util.ResourceFileUtil; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -64,7 +67,7 @@ import org.springframework.scheduling.annotation.EnableScheduling; @EnableScheduling public class Application extends SpringBootServletInitializer { - protected static final EELFLogger EELF_LOGGER = EELFManager.getInstance().getLogger(Application.class); + protected static final EELFLogger eelfLogger = EELFManager.getInstance().getLogger(Application.class); // This settings is an additional one to Spring config, // only if we want to have an additional port automatically redirected to // HTTPS @@ -85,7 +88,6 @@ public class Application extends SpringBootServletInitializer { } public static void main(String[] args) { - EELF_LOGGER.info("Starting :: CLAMP :: (v"+ ClampVersioning.getCldsVersionFromProps()+")"); // This is to initialize some Onap Clamp components initializeComponents(); // Start the Spring application @@ -100,9 +102,11 @@ public class Application extends SpringBootServletInitializer { * This method is used to declare the camel servlet. * * @return A servlet bean + * @throws IOException */ @Bean - public ServletRegistrationBean camelServletRegistrationBean() { + public ServletRegistrationBean camelServletRegistrationBean() throws IOException { + eelfLogger.info(ResourceFileUtil.getResourceAsString("boot-message.txt")+"(v"+ ClampVersioning.getCldsVersionFromProps()+")"+System.getProperty("line.separator")); ServletRegistrationBean registration = new ServletRegistrationBean(new ClampServlet(), "/restservices/clds/v1/*"); registration.setName("CamelServlet"); @@ -130,7 +134,7 @@ public class Application extends SpringBootServletInitializer { private Connector createRedirectConnector(int redirectSecuredPort) { if (redirectSecuredPort <= 0) { - EELF_LOGGER.warn( + eelfLogger.warn( "HTTP port redirection to HTTPS is disabled because the HTTPS port is 0 (random port) or -1 (Connector disabled)"); return null; } diff --git a/src/main/resources/application-noaaf.properties b/src/main/resources/application-noaaf.properties index c1a32b7f..db817a0e 100644 --- a/src/main/resources/application-noaaf.properties +++ b/src/main/resources/application-noaaf.properties @@ -100,6 +100,10 @@ async.core.pool.size=10 async.max.pool.size=20 async.queue.capacity=500 +#For EELF logback file +#com.att.eelf.logging.path= +com.att.eelf.logging.file=logback-default.xml +#The log folder that will be used in logback.xml file clamp.config.log.path=/var/log/onap clamp.config.files.systemProperties=classpath:/system.properties clamp.config.files.cldsUsers=classpath:/clds/clds-users.json diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8694cd8d..24ecc4f9 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -113,6 +113,10 @@ async.core.pool.size=10 async.max.pool.size=20 async.queue.capacity=500 +#For EELF logback file +#com.att.eelf.logging.path= +com.att.eelf.logging.file=logback-default.xml +#The log folder that will be used in logback.xml file clamp.config.log.path=/var/log/onap clamp.config.files.systemProperties=classpath:/system.properties clamp.config.files.cldsUsers=classpath:/clds/clds-users.json diff --git a/src/main/resources/boot-message.txt b/src/main/resources/boot-message.txt new file mode 100644 index 00000000..734af3c6 --- /dev/null +++ b/src/main/resources/boot-message.txt @@ -0,0 +1,7 @@ + + ___ _ ___ __ __ ___ + / __| | | / \ | \/ | | _ \ + | (__ | |__ | - | | |\/| | | _/ + \___| |____| |_|_| |_|__|_| _|_|_ +_|"""""|_|"""""|_|"""""|_|"""""|_| """ | +"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-' diff --git a/src/main/resources/logback-default.xml b/src/main/resources/logback-default.xml new file mode 100644 index 00000000..801e4e47 --- /dev/null +++ b/src/main/resources/logback-default.xml @@ -0,0 +1,237 @@ + + + + + + + + INFO + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n + + + + + + + INFO + + ${logDirectory}/clamp/error.log + true + + %date{"yyyy-MM-dd'T'HH:mm:ss,SSSXXX", + UTC}|%X{RequestId}|%.20thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%.-5level|%X{ErrorCode}|%X{ErrorDescription}|%msg%n + + + + 10 + ${logDirectory}/clamp/error.%i.log.zip + + + + 10MB + + + + + ${logDirectory}/clamp/debug.log + true + + %date{"yyyy-MM-dd'T'HH:mm:ss,SSSXXX",UTC}|%X{RequestId}|%.20thread|%.-5level|%logger{36}|%msg%n + + + + ${logDirectory}/clamp/debug.%d{yyyy-MM-dd}.%i.log.zip + + + 10MB + + 5 + + + + + ${logDirectory}/clamp/audit.log + true + + %X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%.20thread|%X{VirtualServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Unused}|%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n + + + + 10 + ${logDirectory}/clamp/audit.%i.log.zip + + + + 10MB + + + + 256 + + + + + ${logDirectory}/clamp/metric.log + true + + %X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%.20thread|%X{VirtualServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Unused}|%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}| + %msg%n + + + 10 + ${logDirectory}/clamp/metric.%i.log.zip + + + + 10MB + + + + 256 + + + + + + ${logDirectory}/clamp/security.log + true + + %X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%.20thread|%X{VirtualServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Unused}|%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n + + + + 10 + ${logDirectory}/clamp/security.%i.log.zip + + + + 10MB + + + + 256 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${logDirectory}/Audit-${lrmRVer}-${lrmRO}-${Pid}.log + + ${logDirectory}/Audit-${lrmRVer}-${lrmRO}-${Pid}.%i.log.zip + + 1 + 9 + + + 5MB + + + "%d [%thread] %-5level %logger{1024} - %msg%n" + + + + + + ${logDirectory}/Perform-${lrmRVer}-${lrmRO}-${Pid}.log + + ${logDirectory}/Perform-${lrmRVer}-${lrmRO}-${Pid}.%i.log.zip + + 1 + 9 + + + 5MB + + + "%d [%thread] %-5level %logger{1024} - %msg%n" + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 1b554250..dae39d3a 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -1,224 +1,22 @@ - - - - - - - - - - INFO - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n - - - - - - - INFO - - ${logDirectory}/clamp/error.log - true - - %date{"yyyy-MM-dd'T'HH:mm:ss,SSSXXX", UTC}|%X{RequestId}|%.20thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%.-5level|%X{ErrorCode}|%X{ErrorDescription}|%msg%n - - - 10 - ${logDirectory}/clamp/error.%i.log.zip - - - - 10MB - - - - - ${logDirectory}/clamp/debug.log - true - - %date{"yyyy-MM-dd'T'HH:mm:ss,SSSXXX",UTC}|%X{RequestId}|%.20thread|%.-5level|%logger{36}|%msg%n - - - ${logDirectory}/clamp/debug.%d{yyyy-MM-dd}.%i.log.zip - - 10MB - - 5 - - - - - ${logDirectory}/clamp/audit.log - true - - %X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%.20thread|%X{VirtualServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Unused}|%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n - - - - 10 - ${logDirectory}/clamp/audit.%i.log.zip - - - - 10MB - - - - 256 - - - - - ${logDirectory}/clamp/metric.log - true - - %X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%.20thread|%X{VirtualServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Unused}|%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}| - %msg%n - - - 10 - ${logDirectory}/clamp/metric.%i.log.zip - - - - 10MB - - - - 256 - - - - - - ${logDirectory}/clamp/security.log - true - - %X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%.20thread|%X{VirtualServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Unused}|%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%msg%n - - - - 10 - ${logDirectory}/clamp/security.%i.log.zip - - - - 10MB - - - - 256 - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${logDirectory}/Audit-${lrmRVer}-${lrmRO}-${Pid}.log - - ${logDirectory}/Audit-${lrmRVer}-${lrmRO}-${Pid}.%i.log.zip - - 1 - 9 - - - 5MB - - - "%d [%thread] %-5level %logger{1024} - %msg%n" - - - - - - ${logDirectory}/Perform-${lrmRVer}-${lrmRO}-${Pid}.log - - ${logDirectory}/Perform-${lrmRVer}-${lrmRO}-${Pid}.%i.log.zip - - 1 - 9 - - - 5MB - - - "%d [%thread] %-5level %logger{1024} - %msg%n" - - - - - - - - - - - - + + + + + + + + + + - - - - \ No newline at end of file diff --git a/src/main/resources/system.properties b/src/main/resources/system.properties index 0ecba955..a24b6202 100644 --- a/src/main/resources/system.properties +++ b/src/main/resources/system.properties @@ -20,12 +20,6 @@ # =================================================================== # ### - -com.att.eelf.logging.file=classpath:/logback.xml - -# change as per logback.xml path -com.att.eelf.logging.path=./ -logging.config=classpath:/logback.xml # # JVM SSL/TLS properties jdk.tls.client.protocols=TLSv1.1,TLSv1.2 diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index d9d0f0ee..acf64521 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -62,7 +62,7 @@ server.port=8080 server.servlet.context-path=/ #Modified engine-rest applicationpath -spring.profiles.active=clamp-default,clamp-spring-authentication,clamp-sdc-controller +spring.profiles.active=clamp-default,clamp-default-user,clamp-sdc-controller #The max number of active threads in this pool server.tomcat.max-threads=200 @@ -108,6 +108,10 @@ async.core.pool.size=10 async.max.pool.size=20 async.queue.capacity=500 +#For EELF logback file +#com.att.eelf.logging.path= +com.att.eelf.logging.file=logback-default.xml +#The log folder that will be used in logback.xml file clamp.config.log.path=log clamp.config.files.systemProperties=classpath:/system.properties clamp.config.files.cldsUsers=classpath:/clds/clds-users.json diff --git a/src/test/resources/https/https-test.properties b/src/test/resources/https/https-test.properties index 853466e1..e15ea6ed 100644 --- a/src/test/resources/https/https-test.properties +++ b/src/test/resources/https/https-test.properties @@ -87,3 +87,9 @@ camel.defaultthreadpool.rejectpolicy=CallerRuns camel.springboot.xmlRoutes=classpath:/clds/camel/routes/*.xml camel.springboot.xmlRests=classpath:/clds/camel/rest/*.xml #camel.springboot.typeConversion = false + +#For EELF logback file +#com.att.eelf.logging.path= +com.att.eelf.logging.file=logback-default.xml +#The log folder that will be used in logback.xml file +clamp.config.log.path=log \ No newline at end of file -- 2.16.6