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 package org.apache.logging.log4j.core.jmx; 018 019 import java.io.IOException; 020 import java.net.URI; 021 import java.net.URISyntaxException; 022 import java.util.Map; 023 024 /** 025 * The MBean interface for monitoring and managing a {@code LoggerContext}. 026 */ 027 public interface LoggerContextAdminMBean { 028 /** ObjectName pattern for LoggerContextAdmin MBeans. */ 029 String PATTERN = "org.apache.logging.log4j2:type=LoggerContext,ctx=%s"; 030 031 /** 032 * Notification that the {@code Configuration} of the instrumented 033 * {@code LoggerContext} has been reconfigured. Notifications of this type 034 * do not carry a message or user data. 035 */ 036 String NOTIF_TYPE_RECONFIGURED = "com.apache.logging.log4j.core.jmx.config.reconfigured"; 037 038 /** 039 * Returns the status of the instrumented {@code LoggerContext}. 040 * 041 * @return the LoggerContext status. 042 */ 043 String getStatus(); 044 045 /** 046 * Returns the name of the instrumented {@code LoggerContext}. 047 * 048 * @return the name of the instrumented {@code LoggerContext}. 049 */ 050 String getName(); 051 052 /** 053 * Returns the configuration location URI as a String. 054 * 055 * @return the configuration location 056 */ 057 String getConfigLocationURI(); 058 059 /** 060 * Sets the configuration location to the specified URI. This will cause the 061 * instrumented {@code LoggerContext} to reconfigure. 062 * 063 * @param configLocationURI location of the configuration file in 064 * {@link URI} format. 065 * @throws URISyntaxException if the format of the specified 066 * configLocationURI is incorrect 067 * @throws IOException if an error occurred reading the specified location 068 */ 069 void setConfigLocationURI(String configLocation) throws URISyntaxException, 070 IOException; 071 072 /** 073 * Returns the configuration text, which may be the contents of the 074 * configuration file or the text that was last set with a call to 075 * {@code setConfigText}. 076 * 077 * @return the configuration text 078 */ 079 String getConfigText() throws IOException; 080 081 /** 082 * Sets the configuration text. This does not replace the contents of the 083 * configuration file, but <em>does</em> cause the instrumented 084 * {@code LoggerContext} to be reconfigured with the specified text. 085 * 086 * @param configText the configuration text in XML or JSON format 087 * @param charsetName name of the {@code Charset} used to convert the 088 * specified configText to bytes 089 * @throws IllegalArgumentException if a problem occurs configuring from the 090 * specified text 091 */ 092 void setConfigText(String configText, String charsetName); 093 094 /** 095 * Returns the name of the Configuration of the instrumented LoggerContext. 096 * 097 * @return the Configuration name 098 */ 099 String getConfigName(); 100 101 /** 102 * Returns the class name of the {@code Configuration} of the instrumented 103 * LoggerContext. 104 * 105 * @return the class name of the {@code Configuration}. 106 */ 107 String getConfigClassName(); 108 109 /** 110 * Returns a string description of all Filters configured in the 111 * {@code Configuration} of the instrumented LoggerContext. 112 * 113 * @return a string description of all Filters configured 114 */ 115 String getConfigFilter(); 116 117 /** 118 * Returns the class name of the object that is monitoring the configuration 119 * file for modifications. 120 * 121 * @return the class name of the object that is monitoring the configuration 122 * file for modifications 123 */ 124 String getConfigMonitorClassName(); 125 126 /** 127 * Returns a map with configured properties. 128 * 129 * @return a map with configured properties. 130 */ 131 Map<String, String> getConfigProperties(); 132 133 }