use of org.apache.logging.log4j.core.config.ConfiguratonFileWatcher in project mule by mulesoft.
the class LoggerContextConfigurerTestCase method configurationMonitor.
@Test
public void configurationMonitor() throws Exception {
WatchManager watchManager = mock(WatchManager.class);
when(configuration.getWatchManager()).thenReturn(watchManager);
when(context.getConfigFile()).thenReturn(new File(CURRENT_DIRECTORY).toURI());
contextConfigurer.configure(context);
ArgumentCaptor<ConfiguratonFileWatcher> captor = ArgumentCaptor.forClass(ConfiguratonFileWatcher.class);
verify(watchManager).watchFile(any(File.class), captor.capture());
assertThat(captor.getValue(), instanceOf(ConfiguratonFileWatcher.class));
verify(watchManager).setIntervalSeconds(eq((int) TimeUnit.MILLISECONDS.toSeconds(MONITOR_INTERVAL)));
}
use of org.apache.logging.log4j.core.config.ConfiguratonFileWatcher in project mule by mulesoft.
the class LoggerContextConfigurer method configureMonitor.
private void configureMonitor(MuleLoggerContext context) {
Configuration configuration = context.getConfiguration();
File configFile = null;
if (context.getConfigFile() != null) {
configFile = new File(context.getConfigFile().getPath());
} else if (!StringUtils.isEmpty(configuration.getName())) {
configFile = new File(configuration.getName());
}
if (configFile != null && configuration instanceof Reconfigurable) {
configuration.getWatchManager().setIntervalSeconds(DEFAULT_MONITOR_INTERVAL_SECS);
FileWatcher watcher = new ConfiguratonFileWatcher((Reconfigurable) configuration, getListeners(configuration));
configuration.getWatchManager().watchFile(configFile, watcher);
}
}
use of org.apache.logging.log4j.core.config.ConfiguratonFileWatcher in project logging-log4j2 by apache.
the class BuiltConfiguration method setMonitorInterval.
public void setMonitorInterval(final int intervalSeconds) {
if (this instanceof Reconfigurable && intervalSeconds > 0) {
final ConfigurationSource configSource = getConfigurationSource();
if (configSource != null) {
final File configFile = configSource.getFile();
if (intervalSeconds > 0) {
getWatchManager().setIntervalSeconds(intervalSeconds);
if (configFile != null) {
final FileWatcher watcher = new ConfiguratonFileWatcher((Reconfigurable) this, listeners);
getWatchManager().watchFile(configFile, watcher);
}
}
}
}
}
Aggregations