2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.drools.eelf;
23 import java.nio.file.Path;
24 import java.nio.file.Paths;
26 import org.onap.policy.common.logging.eelf.Configuration;
27 import org.onap.policy.common.logging.flexlogger.FlexLogger;
28 import org.onap.policy.common.logging.flexlogger.Logger;
29 import org.onap.policy.drools.features.PolicyEngineFeatureAPI;
30 import org.onap.policy.drools.system.Main;
31 import org.onap.policy.drools.system.PolicyEngine;
34 * Feature EELF : Enables EELF Logging Libraries .
36 public class EelfFeature implements PolicyEngineFeatureAPI {
39 public final boolean beforeBoot(PolicyEngine engine, String[] cliArgs) {
41 String logback = System.getProperty(Main.LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY,
42 Main.LOGBACK_CONFIGURATION_FILE_DEFAULT);
43 Path logbackPath = Paths.get(logback);
45 if (System.getProperty(Configuration.PROPERTY_LOGGING_FILE_PATH) == null) {
46 System.setProperty(Configuration.PROPERTY_LOGGING_FILE_PATH,
47 logbackPath.toAbsolutePath().getParent().toString());
50 if (System.getProperty(Configuration.PROPERTY_LOGGING_FILE_NAME) == null) {
51 System.setProperty(Configuration.PROPERTY_LOGGING_FILE_NAME,
52 logbackPath.getFileName().toString());
55 Logger logger = FlexLogger.getLogger(this.getClass(), true);
57 if (logger.isInfoEnabled()) {
58 logProperty(logger, Main.LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY);
59 logProperty(logger, Configuration.PROPERTY_LOGGING_FILE_PATH);
60 logProperty(logger, Configuration.PROPERTY_LOGGING_FILE_NAME);
66 private void logProperty(Logger logger, String propnm) {
67 logger.info("eelf-feature: Property " + propnm + "=" + System.getProperty(propnm));
71 public int getSequenceNumber() {