本文整理汇总了Java中org.jboss.logmanager.Configurator类的典型用法代码示例。如果您正苦于以下问题:Java Configurator类的具体用法?Java Configurator怎么用?Java Configurator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Configurator类属于org.jboss.logmanager包,在下文中一共展示了Configurator类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOrCreateConfigurationPersistence
import org.jboss.logmanager.Configurator; //导入依赖的package包/类
/**
* Gets the property configurator. If the {@link ConfigurationPersistence} does not exist a new one is created.
*
* @param logContext the log context used to find the property configurator or to attach it to.
*
* @return the property configurator
*/
public static ConfigurationPersistence getOrCreateConfigurationPersistence(final LogContext logContext) {
final Logger root = logContext.getLogger(CommonAttributes.ROOT_LOGGER_NAME);
final ConfigurationPersistence result;
synchronized (LOCK) {
Configurator configurator = root.getAttachment(Configurator.ATTACHMENT_KEY);
if (configurator == null) {
configurator = new ConfigurationPersistence(logContext);
Configurator existing = root.attachIfAbsent(Configurator.ATTACHMENT_KEY, configurator);
if (existing != null) {
configurator = existing;
}
}
if (configurator instanceof ConfigurationPersistence) {
// We have the correct configurator
result = (ConfigurationPersistence) configurator;
} else if (configurator instanceof PropertyConfigurator) {
// Create a new configurator delegating to the configurator found
result = new ConfigurationPersistence((PropertyConfigurator) configurator);
root.attach(Configurator.ATTACHMENT_KEY, result);
} else {
// An unknown configurator, log a warning and replace
LoggingLogger.ROOT_LOGGER.replacingConfigurator(configurator);
result = new ConfigurationPersistence(logContext);
root.attach(Configurator.ATTACHMENT_KEY, result);
}
}
return result;
}
示例2: clearLogContext
import org.jboss.logmanager.Configurator; //导入依赖的package包/类
/**
* Attempts to clear the global log context used for embedded servers.
*/
static synchronized void clearLogContext() {
final LogContext embeddedLogContext = Holder.LOG_CONTEXT;
// Remove the configurator and clear the log context
final Configurator configurator = embeddedLogContext.getLogger("").detach(Configurator.ATTACHMENT_KEY);
// If this was a PropertyConfigurator we can use the LogContextConfiguration API to tear down the LogContext
if (configurator instanceof PropertyConfigurator) {
final LogContextConfiguration logContextConfiguration = ((PropertyConfigurator) configurator).getLogContextConfiguration();
clearLogContext(logContextConfiguration);
} else if (configurator instanceof LogContextConfiguration) {
clearLogContext((LogContextConfiguration) configurator);
} else {
// Remove all the handlers and close them as well as reset the loggers
final List<String> loggerNames = Collections.list(embeddedLogContext.getLoggerNames());
for (String name : loggerNames) {
final Logger logger = embeddedLogContext.getLoggerIfExists(name);
if (logger != null) {
final Handler[] handlers = logger.clearHandlers();
if (handlers != null) {
for (Handler handler : handlers) {
handler.close();
}
}
logger.setFilter(null);
logger.setUseParentFilters(false);
logger.setUseParentHandlers(true);
logger.setLevel(Level.INFO);
}
}
}
}
示例3: getConfigurationPersistence
import org.jboss.logmanager.Configurator; //导入依赖的package包/类
/**
* Gets the property configurator. If the {@link ConfigurationPersistence} does not exist a {@code null} is
* returned.
*
* @param logContext the log context used to find the property configurator or to attach it to.
*
* @return the property configurator or {@code null}
*/
public static ConfigurationPersistence getConfigurationPersistence(final LogContext logContext) {
if (logContext == null) return null;
return (ConfigurationPersistence) logContext.getAttachment(CommonAttributes.ROOT_LOGGER_NAME, Configurator.ATTACHMENT_KEY);
}
示例4: replacingConfigurator
import org.jboss.logmanager.Configurator; //导入依赖的package包/类
/**
* Logs a warning message indicating the configurator class is an unknown type and will be replaced.
*
* @param c the class that is being replaced
*/
@LogMessage(level = WARN)
@Message(id = 13, value = "A configurator class, '%s', is not a known configurator and will be replaced.")
void replacingConfigurator(@Transform(TransformType.GET_CLASS) Configurator c);