From eee98a6c984ab48f05fadaf0a126aaa917bfa820 Mon Sep 17 00:00:00 2001 From: egernug Date: Thu, 4 Jul 2019 15:13:15 +0000 Subject: Functionality and Pattern changes for Node logging Change-Id: Ief4cd3dc824f1454ba58db63e79694a4cda77712 Issue-ID: DMAAP-1049 Signed-off-by: egernug --- .../dmaap/datarouter/node/eelf/AuditFilter.java | 38 +++ .../dmaap/datarouter/node/eelf/EELFFilter.java | 43 --- .../dmaap/datarouter/node/eelf/JettyFilter.java | 36 +++ .../dmaap/datarouter/node/eelf/MetricsFilter.java | 41 +++ .../src/main/resources/docker/Dockerfile | 2 +- datarouter-node/src/main/resources/logback.xml | 302 ++++++--------------- 6 files changed, 197 insertions(+), 265 deletions(-) create mode 100644 datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/AuditFilter.java delete mode 100644 datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/EELFFilter.java create mode 100644 datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/JettyFilter.java create mode 100644 datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/MetricsFilter.java (limited to 'datarouter-node/src') diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/AuditFilter.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/AuditFilter.java new file mode 100644 index 00000000..33103db5 --- /dev/null +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/AuditFilter.java @@ -0,0 +1,38 @@ +/*- + * ============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.dmaap.datarouter.node.eelf; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.filter.Filter; +import ch.qos.logback.core.spi.FilterReply; + + +public class AuditFilter extends Filter { + @Override + public FilterReply decide(ILoggingEvent event) { + if (event.getMessage().contains("DEL|") || event.getMessage().contains("PUB|") || event.getMessage().contains("PBF|") + || event.getMessage().contains("EXP|") || event.getMessage().contains("DLX|")) { + return FilterReply.ACCEPT; + } else { + return FilterReply.DENY; + } + } +} diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/EELFFilter.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/EELFFilter.java deleted file mode 100644 index b733e7e4..00000000 --- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/EELFFilter.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START================================================== - * * org.onap.dmaap - * * =========================================================================== - * * Copyright © 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==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.dmaap.datarouter.node.eelf; - -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.filter.Filter; -import ch.qos.logback.core.spi.FilterReply; - -/* - * When EELF functionality added it default started logging Jetty logs as well which in turn stopped existing functionality of logging jetty statements in node.log - * added code in logback.xml to add jetty statements in node.log. - * This class removes extran EELF statements from node.log since they are being logged in apicalls.log - */ -public class EELFFilter extends Filter { - @Override - public FilterReply decide(ILoggingEvent event) { - if (event.getMessage().contains("EELF")) { - return FilterReply.DENY; - } else { - return FilterReply.ACCEPT; - } - } -} diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/JettyFilter.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/JettyFilter.java new file mode 100644 index 00000000..39b7d8e2 --- /dev/null +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/JettyFilter.java @@ -0,0 +1,36 @@ +/*- + * ============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.dmaap.datarouter.node.eelf; + +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.filter.Filter; +import ch.qos.logback.core.spi.FilterReply; + + +public class JettyFilter extends Filter { + @Override + public FilterReply decide(ILoggingEvent event) { + if (event.getMessage().contains("org.eclipse.jetty")) { + return FilterReply.ACCEPT; + } else { + return FilterReply.DENY; + } + } +} diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/MetricsFilter.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/MetricsFilter.java new file mode 100644 index 00000000..235dcb2d --- /dev/null +++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/eelf/MetricsFilter.java @@ -0,0 +1,41 @@ +/*- + * ============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.dmaap.datarouter.node.eelf; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.filter.Filter; +import ch.qos.logback.core.spi.FilterReply; + + +public class MetricsFilter extends Filter { + @Override + public FilterReply decide(ILoggingEvent event) { + if (event.getLevel().equals(Level.INFO) && !event.getMessage().contains("jetty")) { + if (!event.getMessage().contains("DEL|") && !event.getMessage().contains("PUB|") && !event.getMessage().contains( + "PBF|") && !event.getMessage().contains("EXP|") && !event.getMessage().contains("DLX|")) { + return FilterReply.ACCEPT; + } + } else { + return FilterReply.DENY; + } + return FilterReply.DENY; + } +} diff --git a/datarouter-node/src/main/resources/docker/Dockerfile b/datarouter-node/src/main/resources/docker/Dockerfile index b07b3ef3..01880bbb 100644 --- a/datarouter-node/src/main/resources/docker/Dockerfile +++ b/datarouter-node/src/main/resources/docker/Dockerfile @@ -35,6 +35,6 @@ ENTRYPOINT ["sh", "startup.sh"] RUN addgroup -S -g 1001 onap \ && adduser -S -u 1000 datarouter -G onap \ - && chown -R datarouter:onap /opt/ + && chown -R datarouter:onap /opt/ /var/ USER datarouter \ No newline at end of file diff --git a/datarouter-node/src/main/resources/logback.xml b/datarouter-node/src/main/resources/logback.xml index cc2ff4e2..dc19cb6f 100644 --- a/datarouter-node/src/main/resources/logback.xml +++ b/datarouter-node/src/main/resources/logback.xml @@ -8,9 +8,9 @@ * 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 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software + * 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 @@ -20,33 +20,19 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. * --> - - - - - + - - - - - - + + + + + + + - - - - - - - - - - + - @@ -64,258 +50,147 @@ log --> - - ${logDirectory}/${generalLogName}.log - - INFO - ACCEPT - DENY + ${logDirectory}/${auditLog}.log + - ${logDirectory}/${generalLogName}.%i.log.zip + ${logDirectory}/${auditLog}.%i.log.zip 1 9 - 5MB + 50MB ${defaultPattern} - + 256 - - - - - + - - - - - - - - + + + - - - - - - - 256 - - - - - ${logDirectory}/${errorLogName}.log - - ERROR + ${logDirectory}/${errorLog}.log + + WARN ACCEPT DENY - ${logDirectory}/${errorLogName}.%i.log.zip + ${logDirectory}/${errorLog}.%i.log.zip 1 9 - 5MB + 50MB ${defaultPattern} - + 256 - + - - ${logDirectory}/${jettyAndNodeLogName}.log - + ${logDirectory}/${jettyLog}.log + - ${logDirectory}/${jettyAndNodeLogName}.%i.log.zip + ${logDirectory}/${jettyLog}.%i.log.zip 1 9 - 5MB + 50MB - ${jettyAndNodeLoggerPattern} + ${defaultPattern} - + 256 - + true @@ -326,49 +201,34 @@ - + - - - - - - - - - + + + - - - + + + + + -- cgit 1.2.3-korg