use of org.apache.log4j.PatternLayout in project accumulo by apache.
the class CombinerTest method runDeleteHandlingTest.
private void runDeleteHandlingTest(TreeMap<Key, Value> input, TreeMap<Key, Value> expected, Boolean rofco, IteratorEnvironment env, String expectedLog, boolean clearLogMsgCache) throws Exception {
boolean deepCopy = expected == null;
if (clearLogMsgCache) {
CombinerTestUtil.clearLogCache();
}
StringWriter writer = new StringWriter();
WriterAppender appender = new WriterAppender(new PatternLayout("%p, %m%n"), writer);
Logger logger = Logger.getLogger(Combiner.class);
boolean additivity = logger.getAdditivity();
try {
logger.addAppender(appender);
logger.setAdditivity(false);
Combiner ai = new SummingCombiner();
IteratorSetting is = new IteratorSetting(1, SummingCombiner.class);
SummingCombiner.setEncodingType(is, LongCombiner.StringEncoder.class);
Combiner.setColumns(is, Collections.singletonList(new IteratorSetting.Column("cf001")));
if (rofco != null) {
Combiner.setReduceOnFullCompactionOnly(is, rofco);
}
ai.init(new SortedMapIterator(input), is.getOptions(), env);
if (deepCopy)
assertEquals(expected, readAll(ai.deepCopy(env)));
assertEquals(expected, readAll(ai));
} finally {
logger.removeAppender(appender);
logger.setAdditivity(additivity);
}
String logMsgs = writer.toString();
if (expectedLog == null) {
Assert.assertTrue("Expected 0 length log message, but got : " + logMsgs, logMsgs.length() == 0);
} else {
logMsgs = logMsgs.replace('\n', ' ');
Assert.assertTrue("Did not match pattern [" + expectedLog + "] in [" + logMsgs + "]", logMsgs.matches(expectedLog));
}
}
use of org.apache.log4j.PatternLayout in project lvm4j by dirmeier.
the class TestSuite method setup.
@BeforeClass
public static void setup() {
ConsoleAppender appender = new ConsoleAppender();
appender.setWriter(new OutputStreamWriter(java.lang.System.out));
appender.setLayout(new PatternLayout("%-5p [%t]: %m%n"));
Logger.getRootLogger().addAppender(appender);
}
use of org.apache.log4j.PatternLayout in project wring by yegor256.
the class Exec method log.
/**
* Push and collect logs.
* @return Logs
* @throws IOException If fails
*/
private String log() throws IOException {
final org.apache.log4j.Logger root = org.apache.log4j.Logger.getRootLogger();
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final Appender appender = new ThreadAppender(new PatternLayout("%t %p %m\n"), baos);
root.addAppender(appender);
try {
this.pipe.status(this.agent.push(this.events));
return baos.toString();
} finally {
root.removeAppender(appender);
}
}
use of org.apache.log4j.PatternLayout in project presto by prestodb.
the class AccumuloModule method configure.
@Override
public void configure(Binder binder) {
// Add appender to Log4J root logger
// create appender
JulAppender appender = new JulAppender();
appender.setLayout(new PatternLayout("%d %-5p %c - %m%n"));
appender.setThreshold(Level.INFO);
appender.activateOptions();
org.apache.log4j.Logger.getRootLogger().addAppender(appender);
binder.bind(TypeManager.class).toInstance(typeManager);
binder.bind(AccumuloConnector.class).in(Scopes.SINGLETON);
binder.bind(AccumuloConnectorId.class).toInstance(new AccumuloConnectorId(connectorId));
binder.bind(AccumuloMetadata.class).in(Scopes.SINGLETON);
binder.bind(AccumuloMetadataFactory.class).in(Scopes.SINGLETON);
binder.bind(AccumuloClient.class).in(Scopes.SINGLETON);
binder.bind(AccumuloSplitManager.class).in(Scopes.SINGLETON);
binder.bind(AccumuloRecordSetProvider.class).in(Scopes.SINGLETON);
binder.bind(AccumuloPageSinkProvider.class).in(Scopes.SINGLETON);
binder.bind(AccumuloHandleResolver.class).in(Scopes.SINGLETON);
binder.bind(AccumuloSessionProperties.class).in(Scopes.SINGLETON);
binder.bind(AccumuloTableProperties.class).in(Scopes.SINGLETON);
binder.bind(ZooKeeperMetadataManager.class).in(Scopes.SINGLETON);
binder.bind(AccumuloTableManager.class).in(Scopes.SINGLETON);
binder.bind(IndexLookup.class).in(Scopes.SINGLETON);
binder.bind(ColumnCardinalityCache.class).in(Scopes.SINGLETON);
binder.bind(Connector.class).toProvider(ConnectorProvider.class);
configBinder(binder).bindConfig(AccumuloConfig.class);
jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
jsonCodecBinder(binder).bindMapJsonCodec(String.class, JsonCodec.listJsonCodec(AccumuloTable.class));
}
use of org.apache.log4j.PatternLayout in project apex-core by apache.
the class LogFileInformationTest method beforeClass.
@BeforeClass
public static void beforeClass() throws IOException {
String logFileDir = new File("target" + File.separator + "logDir").getAbsolutePath();
logFileName = logFileDir + File.separator + "appTest.log";
RollingFileAppender rfa = new RollingFileAppender(new PatternLayout("%d{ISO8601} [%t] %-5p %c{2} %M - %m%n"), logFileName);
rfa.setName(APPENDER_NAME);
logger.addAppender(rfa);
}
Aggregations