use of org.apache.logging.log4j.core.config.Configuration in project ignite by apache.
the class Log4J2Logger method setLevel.
/**
* Sets level for internal log4j implementation.
*
* @param level Log level to set.
*/
public void setLevel(Level level) {
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration conf = ctx.getConfiguration();
conf.getLoggerConfig(impl.getName()).setLevel(level);
ctx.updateLoggers(conf);
}
use of org.apache.logging.log4j.core.config.Configuration in project logging-log4j2 by apache.
the class ScriptConditionTest method testSelectFilesToDelete2.
@Test
public void testSelectFilesToDelete2() {
final Configuration config = new DefaultConfiguration();
// creates the ScriptManager
config.initialize();
final List<PathWithAttributes> pathList = new ArrayList<>();
pathList.add(new PathWithAttributes(Paths.get("/path/1"), new DummyFileAttributes()));
pathList.add(new PathWithAttributes(Paths.get("/path/2"), new DummyFileAttributes()));
pathList.add(new PathWithAttributes(Paths.get("/path/3"), new DummyFileAttributes()));
final String scriptText = //
"pathList.remove(1);" + "pathList;";
final Script script = new Script("test", "javascript", scriptText);
final ScriptCondition condition = new ScriptCondition(script, config);
final Path base = Paths.get("baseDirectory");
final List<PathWithAttributes> result = condition.selectFilesToDelete(base, pathList);
assertSame(result, pathList);
assertEquals(2, result.size());
assertEquals(Paths.get("/path/1"), result.get(0).getPath());
assertEquals(Paths.get("/path/3"), result.get(1).getPath());
}
use of org.apache.logging.log4j.core.config.Configuration in project logging-log4j2 by apache.
the class RollingFileAppenderAccessTest method testAccessManagerWithBuilder.
/**
* Not a real test, just make sure we can compile access to the typed manager.
*
* @throws IOException
*/
@Test
public void testAccessManagerWithBuilder() throws IOException {
try (final LoggerContext ctx = LoggerContext.getContext(false)) {
final Configuration config = ctx.getConfiguration();
final File file = File.createTempFile("RollingFileAppenderAccessTest", ".tmp");
file.deleteOnExit();
// @formatter:off
final RollingFileAppender appender = RollingFileAppender.newBuilder().withFileName(file.getCanonicalPath()).withFilePattern("FilePattern").withName("Name").withPolicy(OnStartupTriggeringPolicy.createPolicy(1)).setConfiguration(config).build();
// @formatter:on
final RollingFileManager manager = appender.getManager();
// Since the RolloverStrategy and TriggeringPolicy are immutable, we could also use generics to type their
// access.
Assert.assertNotNull(manager.getRolloverStrategy());
Assert.assertNotNull(manager.getTriggeringPolicy());
}
}
use of org.apache.logging.log4j.core.config.Configuration in project logging-log4j2 by apache.
the class ScriptConditionTest method testSelectFilesToDelete.
@Test
public void testSelectFilesToDelete() {
final Configuration config = new DefaultConfiguration();
// creates the ScriptManager
config.initialize();
// script that returns pathList
final Script script = new Script("test", "javascript", "pathList;");
final ScriptCondition condition = new ScriptCondition(script, config);
final List<PathWithAttributes> pathList = new ArrayList<>();
final Path base = Paths.get("baseDirectory");
final List<PathWithAttributes> result = condition.selectFilesToDelete(base, pathList);
assertSame(result, pathList);
}
use of org.apache.logging.log4j.core.config.Configuration in project logging-log4j2 by apache.
the class DeleteActionTest method create.
private static DeleteAction create(final String path, final boolean followLinks, final int maxDepth, final boolean testMode, final PathCondition[] conditions) {
final Configuration config = new BasicConfigurationFactory().new BasicConfiguration();
final DeleteAction delete = DeleteAction.createDeleteAction(path, followLinks, maxDepth, testMode, null, conditions, null, config);
return delete;
}
Aggregations