2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Modifications Copyright (c) 2019 Samsung
\r
8 * ================================================================================
\r
9 * Licensed under the Apache License, Version 2.0 (the "License");
\r
10 * you may not use this file except in compliance with the License.
\r
11 * You may obtain a copy of the License at
\r
13 * http://www.apache.org/licenses/LICENSE-2.0
\r
15 * Unless required by applicable law or agreed to in writing, software
\r
16 * distributed under the License is distributed on an "AS IS" BASIS,
\r
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
18 * See the License for the specific language governing permissions and
\r
19 * limitations under the License.
\r
20 * ============LICENSE_END=========================================================
\r
23 package org.oran.otf.common.utility.logger;
\r
25 import ch.qos.logback.classic.Level;
\r
26 import ch.qos.logback.classic.LoggerContext;
\r
27 import ch.qos.logback.classic.spi.LoggerContextListener;
\r
28 import ch.qos.logback.core.Context;
\r
29 import ch.qos.logback.core.spi.ContextAwareBase;
\r
30 import ch.qos.logback.core.spi.LifeCycle;
\r
31 import java.net.InetAddress;
\r
32 import java.net.UnknownHostException;
\r
33 import org.slf4j.Logger;
\r
34 import org.slf4j.LoggerFactory;
\r
35 import org.springframework.stereotype.Component;
\r
38 public class LoggerStartupListener extends ContextAwareBase
\r
39 implements LoggerContextListener, LifeCycle {
\r
41 private static final Logger logger = LoggerFactory.getLogger(LoggerStartupListener.class);
\r
42 private boolean started = false;
\r
45 public void start() {
\r
49 InetAddress addr = null;
\r
51 addr = InetAddress.getLocalHost();
\r
52 } catch (UnknownHostException e) {
\r
53 logger.error("UnknownHostException", e);
\r
55 Context context = getContext();
\r
57 context.putProperty("server.name", addr.getHostName());
\r
63 public void stop() {
\r
67 public boolean isStarted() {
\r
72 public boolean isResetResistant() {
\r
77 public void onReset(LoggerContext arg0) {
\r
81 public void onStart(LoggerContext arg0) {
\r
85 public void onStop(LoggerContext arg0) {
\r
89 public void onLevelChange(ch.qos.logback.classic.Logger logger, Level level) {
\r