001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache license, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the license for the specific language governing permissions and 015 * limitations under the license. 016 */ 017 018package org.apache.logging.log4j.core.config; 019 020import java.util.Objects; 021 022import org.apache.logging.log4j.Level; 023import org.apache.logging.log4j.Marker; 024import org.apache.logging.log4j.core.LogEvent; 025import org.apache.logging.log4j.message.Message; 026import org.apache.logging.log4j.util.Supplier; 027 028/** 029 * Reliability strategy that assumes reconfigurations will never take place. 030 */ 031public class DefaultReliabilityStrategy implements ReliabilityStrategy { 032 033 private final LoggerConfig loggerConfig; 034 035 public DefaultReliabilityStrategy(final LoggerConfig loggerConfig) { 036 this.loggerConfig = Objects.requireNonNull(loggerConfig, "loggerConfig is null"); 037 } 038 039 /* 040 * (non-Javadoc) 041 * 042 * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier, 043 * java.lang.String, java.lang.String, org.apache.logging.log4j.Marker, org.apache.logging.log4j.Level, 044 * org.apache.logging.log4j.message.Message, java.lang.Throwable) 045 */ 046 @Override 047 public void log(Supplier<LoggerConfig> reconfigured, String loggerName, String fqcn, Marker marker, Level level, 048 Message data, Throwable t) { 049 loggerConfig.log(loggerName, fqcn, marker, level, data, t); 050 } 051 052 /* 053 * (non-Javadoc) 054 * 055 * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier, 056 * org.apache.logging.log4j.core.LogEvent) 057 */ 058 @Override 059 public void log(Supplier<LoggerConfig> reconfigured, LogEvent event) { 060 loggerConfig.log(event); 061 } 062 063 /* 064 * (non-Javadoc) 065 * 066 * @see 067 * org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeLogEvent(org.apache.logging.log4j.core.config. 068 * LoggerConfig, org.apache.logging.log4j.util.Supplier) 069 */ 070 @Override 071 public LoggerConfig getActiveLoggerConfig(Supplier<LoggerConfig> next) { 072 return this.loggerConfig; 073 } 074 075 /* 076 * (non-Javadoc) 077 * 078 * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#afterLogEvent() 079 */ 080 @Override 081 public void afterLogEvent() { 082 // no action 083 } 084 085 /* 086 * (non-Javadoc) 087 * 088 * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopAppenders() 089 */ 090 @Override 091 public void beforeStopAppenders() { 092 // no action 093 } 094 095 /* (non-Javadoc) 096 * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopConfiguration(org.apache.logging.log4j.core.config.Configuration) 097 */ 098 @Override 099 public void beforeStopConfiguration(Configuration configuration) { 100 // no action 101 } 102 103}