2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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 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());
49 if (System.getProperty(Configuration.PROPERTY_LOGGING_FILE_NAME) == null)
50 System.setProperty(Configuration.PROPERTY_LOGGING_FILE_NAME,
51 logbackPath.getFileName().toString());
53 Logger logger = FlexLogger.getLogger(this.getClass(), true);
55 if (logger.isInfoEnabled()) {
56 logger.info("eelf-feature: Property " + Main.LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY + "=" +
57 System.getProperty(Main.LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY));
58 logger.info("eelf-feature: Property " + Configuration.PROPERTY_LOGGING_FILE_PATH + "=" +
59 System.getProperty(Configuration.PROPERTY_LOGGING_FILE_PATH));
60 logger.info("eelf-feature: Property " + Configuration.PROPERTY_LOGGING_FILE_NAME + "=" +
61 System.getProperty(Configuration.PROPERTY_LOGGING_FILE_NAME));
68 public int getSequenceNumber() {