diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/resources/log4j2.properties (renamed from src/main/resources/log4j.properties) | 36 | ||||
-rw-r--r-- | src/main/webapp/WEB-INF/log4j.xml | 45 | ||||
-rw-r--r-- | src/main/webapp/WEB-INF/log4j2.xml | 50 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/dbcapi/database/DBFieldHandlerTest.java | 6 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/dbcapi/model/JUnitTestSuite.java | 26 | ||||
-rw-r--r-- | src/test/java/org/onap/dmaap/dbcapi/model/TestRunner.java | 31 |
6 files changed, 108 insertions, 86 deletions
diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j2.properties index bfaeaf2..23ac122 100644 --- a/src/main/resources/log4j.properties +++ b/src/main/resources/log4j2.properties @@ -1,29 +1,39 @@ ### # ============LICENSE_START======================================================= -# OpenECOMP - org.openecomp.dmaapbc -# ================================================================================ -# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# Copyright (C) 2021 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========================================================= ### -log4j.debug=FALSE -log4j.rootLogger=INFO,Root +# Log4j2 PropertiesConfig +status=info +name=PropertiesConfig + +# Rolling Appender +appender.rolling.type=RollingFile +appender.rolling.name=rollingFile +appender.rolling.fileName=logs/dmaapBC-api.log +appender.rolling.filePattern=/tmp/$${date:yyyy-MM-dd}/dmaapBC-api-%d{yyyy-MM-dd}-%i.log +appender.rolling.layout.type=PatternLayout +appender.rolling.layout.pattern=%d %p %F %L %t %m%n +appender.rolling.policies.type=Policies +appender.rolling.policies.time.type=TimeBasedTriggeringPolicy +appender.rolling.policies.time.interval=1 +appender.rolling.policies.time.modulate=true -log4j.appender.Root=org.apache.log4j.DailyRollingFileAppender -log4j.appender.Root.file=logs/dmaapBC-api.log -log4j.appender.Root.datePattern='.'yyyyMMdd -log4j.appender.Root.append=true -log4j.appender.Root.layout=org.apache.log4j.PatternLayout -log4j.appender.Root.layout.ConversionPattern=%d %p %F %L %t %m%n +# Root Logger +rootLogger.level=info +rootLogger.appenderRef.rolling.ref=rollingFile
\ No newline at end of file diff --git a/src/main/webapp/WEB-INF/log4j.xml b/src/main/webapp/WEB-INF/log4j.xml deleted file mode 100644 index 4e4d5e9..0000000 --- a/src/main/webapp/WEB-INF/log4j.xml +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - OpenECOMP - org.openecomp.dmaapbc - ================================================================================ - Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - ================================================================================ - 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. - ============LICENSE_END========================================================= - --> - -<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" > -<log4j:configuration> - <appender name="dmaapBC" class="org.apache.log4j.RollingFileAppender"> - <param name="File" value="dmaapBC.log"/> - <param name="MaxFileSize" value="1000KB"/> - <param name="MaxBackupIndex" value="3"/> - <layout class="org.apache.log4j.PatternLayout"> - <param name="ConversionPattern" value="[%d{HH:mm:ss:SSS}] - %-6p - %c.%M() - %m%n"/> - </layout> - </appender> - <appender name="media" class="org.apache.log4j.ConsoleAppender"> - <param name="Threshold" value="FATAL"/> - <layout class="org.apache.log4j.PatternLayout"> - <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/> - </layout> - </appender> - <category name="org.openecomp.dcae.dmaapBC"> - <appender-ref ref="dmaapBC"/> - </category> - <root> - <priority value="all"/> - <appender-ref ref="media"/> - </root> -</log4j:configuration> diff --git a/src/main/webapp/WEB-INF/log4j2.xml b/src/main/webapp/WEB-INF/log4j2.xml new file mode 100644 index 0000000..bd7e9c5 --- /dev/null +++ b/src/main/webapp/WEB-INF/log4j2.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ============LICENSE_START======================================================= + Copyright (C) 2021 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========================================================= + --> + +<Configuration status="WARN"> + <Appenders> + <!-- Console Appender --> + <Console name="STDOUT" target="SYSTEM_OUT"> + <PatternLayout pattern="%d %-5r %-5p [%c] (%t:%x) %m%n"/> + </Console> + + <!-- Rolling File Appender --> + <RollingFile name="rollingFile"> + <FileName>dmaapBC.log</FileName> + <FilePattern>${date:yyyy-MM}/dmaapBC-%d{yyyy-MM-dd}-%i.log.gz</FilePattern> + <PatternLayout> + <Pattern>[%d{HH:mm:ss:SSS}] - %-6p - %c.%M() - %m%n</Pattern> + </PatternLayout> + <Policies> + <SizeBasedTriggeringPolicy size="1000 KB"/> + </Policies> + <DefaultRolloverStrategy max="3"/> + </RollingFile> + </Appenders> + <Loggers> + <Logger name="org.openecomp.dcae.dmaapBC" level="debug" additivity="false"> + <AppenderRef ref="rollingFile"/> + </Logger> + <Root level="ALL"> + <AppenderRef ref="STDOUT"/> + </Root> + </Loggers> +</Configuration>
\ No newline at end of file diff --git a/src/test/java/org/onap/dmaap/dbcapi/database/DBFieldHandlerTest.java b/src/test/java/org/onap/dmaap/dbcapi/database/DBFieldHandlerTest.java index 5171aaa..23745ac 100644 --- a/src/test/java/org/onap/dmaap/dbcapi/database/DBFieldHandlerTest.java +++ b/src/test/java/org/onap/dmaap/dbcapi/database/DBFieldHandlerTest.java @@ -27,8 +27,8 @@ import static org.junit.Assert.assertNull; import java.sql.PreparedStatement; import java.sql.ResultSet; - -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.Test; import org.onap.dmaap.dbcapi.authentication.AafLurAndFish; import org.onap.dmaap.dbcapi.model.ReplicationType; @@ -36,7 +36,7 @@ import org.onap.dmaap.dbcapi.testframework.ReflectionHarness; public class DBFieldHandlerTest { - private static final Logger logger = Logger.getLogger(AafLurAndFish.class); + private static final Logger logger = LogManager.getLogger(AafLurAndFish.class); private static final String fmt = "%24s: %s%n"; diff --git a/src/test/java/org/onap/dmaap/dbcapi/model/JUnitTestSuite.java b/src/test/java/org/onap/dmaap/dbcapi/model/JUnitTestSuite.java index 1c8edc0..a55e420 100644 --- a/src/test/java/org/onap/dmaap/dbcapi/model/JUnitTestSuite.java +++ b/src/test/java/org/onap/dmaap/dbcapi/model/JUnitTestSuite.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. @@ -21,20 +21,22 @@ package org.onap.dmaap.dbcapi.model; import junit.framework.TestSuite; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; -import org.apache.log4j.Logger; @RunWith(Suite.class) -@SuiteClasses({ DmaapTest.class - }) +@SuiteClasses({DmaapTest.class}) public class JUnitTestSuite { - private static final Logger LOGGER = Logger.getLogger(JUnitTestSuite.class); - public static void main(String[] args) { - LOGGER.info("Running the test suite"); - - TestSuite tstSuite = new TestSuite(); - LOGGER.info("Total Test Counts " + tstSuite.countTestCases()); - } + + private static final Logger logger = LogManager.getLogger(JUnitTestSuite.class); + + public static void main(String[] args) { + logger.info("Running the test suite"); + + TestSuite tstSuite = new TestSuite(); + logger.info("Total Test Counts " + tstSuite.countTestCases()); + } } diff --git a/src/test/java/org/onap/dmaap/dbcapi/model/TestRunner.java b/src/test/java/org/onap/dmaap/dbcapi/model/TestRunner.java index fcab3e1..66cec35 100644 --- a/src/test/java/org/onap/dmaap/dbcapi/model/TestRunner.java +++ b/src/test/java/org/onap/dmaap/dbcapi/model/TestRunner.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. @@ -18,19 +18,24 @@ * ============LICENSE_END========================================================= */ package org.onap.dmaap.dbcapi.model; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.runner.JUnitCore; import org.junit.runner.Result; import org.junit.runner.notification.Failure; -import org.apache.log4j.Logger; + public class TestRunner { - private static final Logger LOGGER = Logger.getLogger(TestRunner.class); - public static void main(String[] args) { - - Result result = JUnitCore.runClasses(JUnitTestSuite.class); - for (Failure failure : result.getFailures()) { - LOGGER.info(failure.toString()); - - } - LOGGER.info(result.wasSuccessful()); - } + + private static final Logger logger = LogManager.getLogger(TestRunner.class); + + public static void main(String[] args) { + + Result result = JUnitCore.runClasses(JUnitTestSuite.class); + for (Failure failure : result.getFailures()) { + logger.info(failure.toString()); + + } + logger.info(result.wasSuccessful()); + } } |