use of org.apache.log4j.SimpleLayout in project databus by linkedin.
the class AvroConvertCli method main.
/**
* @param args
*/
public static void main(String[] args) throws Exception {
ConsoleAppender app = new ConsoleAppender(new SimpleLayout());
Logger.getRootLogger().removeAllAppenders();
Logger.getRootLogger().addAppender(app);
AvroConvertCli cli = new AvroConvertCli();
try {
cli.parseCommandLine(args);
} catch (ParseException pe) {
System.err.println(pe.getMessage());
cli.printUsage();
System.exit(1);
}
if (!cli.hasOptions() || cli.hasHelpOption()) {
cli.printUsage();
System.exit(0);
}
int verbosity = cli.getVerbosity();
switch(verbosity) {
case 0:
Logger.getRootLogger().setLevel(Level.ERROR);
break;
case 1:
Logger.getRootLogger().setLevel(Level.INFO);
break;
case 2:
Logger.getRootLogger().setLevel(Level.DEBUG);
break;
default:
Logger.getRootLogger().setLevel(Level.ALL);
break;
}
AvroFormat inputFormat = cli.getInputFormat(AvroFormat.JSON);
LOG.info("Using input format: " + inputFormat);
AvroFormat outputFormat = cli.getOutputFormat(AvroFormat.JSON);
LOG.info("Using output format: " + outputFormat);
String inputSchemaName = cli.getInputSchema(null);
if (null == inputSchemaName) {
System.err.println("Input schema expected");
cli.printUsage();
System.exit(4);
}
Schema inputSchema = null;
try {
inputSchema = openSchema(inputSchemaName);
} catch (IOException ioe) {
System.err.println("Unable to open input schema: " + ioe);
System.exit(2);
}
LOG.info("Using input schema:" + inputSchemaName);
String outputSchemaName = cli.getOutputSchema(inputSchemaName);
Schema outputSchema = null;
try {
outputSchema = outputSchemaName.equals(inputSchemaName) ? inputSchema : openSchema(outputSchemaName);
} catch (IOException ioe) {
System.err.println("Unable to open output schema: " + ioe);
System.exit(3);
}
LOG.info("Using output schema:" + outputSchemaName);
String inputFileName = cli.getInputFileName("-");
InputStream input = inputFileName.equals("-") ? System.in : new FileInputStream(inputFileName);
LOG.info("Using input: " + inputFileName);
String outputFileName = cli.getOutputFileName("-");
OutputStream output = outputFileName.equals("-") ? System.out : new FileOutputStream(outputFileName);
LOG.info("Using output: " + outputFileName);
AvroConverter avroConverter = new AvroConverter(inputFormat, outputFormat, inputSchema, outputSchema);
avroConverter.convert(input, output);
if (!inputFileName.equals("-"))
input.close();
if (!outputFileName.equals("-"))
output.close();
}
use of org.apache.log4j.SimpleLayout in project databus by linkedin.
the class TestFilterToSQL method setUp.
@BeforeClass
public void setUp() throws IOException, DatabusException, InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException {
Logger.getRootLogger().removeAllAppenders();
Appender defApp = new ConsoleAppender(new SimpleLayout());
Logger.getRootLogger().addAppender(defApp);
Logger.getRootLogger().setLevel(Level.INFO);
BootstrapServerConfig configBuilder = new BootstrapServerConfig();
BootstrapServerStaticConfig staticConfig = configBuilder.build();
processor = new BootstrapProcessor(staticConfig, null);
partConf = new KeyFilterConfigHolder.Config();
}
use of org.apache.log4j.SimpleLayout in project ddf by codice.
the class ReliableResourceInputStreamTest method testInputStreamReadRetry.
@Test
public void testInputStreamReadRetry() throws Exception {
LOGGER.info("Testing testInputStreamReadTwice()");
ReliableResourceInputStream is = new ReliableResourceInputStream(fbos, countingFbos, downloadState, downloadIdentifier, resourceResponse);
is.setCallableAndItsFuture(reliableResourceCallable, downloadFuture);
org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(is.getClass());
logger.setLevel(Level.TRACE);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Layout layout = new SimpleLayout();
Appender appender = new WriterAppender(layout, out);
logger.addAppender(appender);
//downloadState.setDownloadState(DownloadManagerState.DownloadState.IN_PROGRESS);
try {
// Write zero bytes to FileBackedOutputStream
byte[] bytes = new String("").getBytes();
countingFbos.write(bytes, 0, bytes.length);
// Attempt to read from FileBackedOutputStream
final byte[] buffer = new byte[50];
int numBytesRead = is.read(buffer, 0, 50);
// Verify bytes read is -1
assertThat(numBytesRead, is(-1));
// Verify read inputstream performed twice
String logMsg = out.toString();
assertThat(logMsg, is(notNullValue()));
assertThat(logMsg, containsString("First time reading inputstream"));
//assertThat(logMsg, containsString("Retry reading inputstream"));
} finally {
logger.removeAppender(appender);
}
}
use of org.apache.log4j.SimpleLayout in project hadoop by apache.
the class TestYARNRunner method testWarnCommandOpts.
@Test(timeout = 20000)
public void testWarnCommandOpts() throws Exception {
Logger logger = Logger.getLogger(YARNRunner.class);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
Layout layout = new SimpleLayout();
Appender appender = new WriterAppender(layout, bout);
logger.addAppender(appender);
JobConf jobConf = new JobConf();
jobConf.set(MRJobConfig.MR_AM_ADMIN_COMMAND_OPTS, "-Djava.net.preferIPv4Stack=true -Djava.library.path=foo");
jobConf.set(MRJobConfig.MR_AM_COMMAND_OPTS, "-Xmx1024m -Djava.library.path=bar");
YARNRunner yarnRunner = new YARNRunner(jobConf);
@SuppressWarnings("unused") ApplicationSubmissionContext submissionContext = buildSubmitContext(yarnRunner, jobConf);
String logMsg = bout.toString();
assertTrue(logMsg.contains("WARN - Usage of -Djava.library.path in " + "yarn.app.mapreduce.am.admin-command-opts can cause programs to no " + "longer function if hadoop native libraries are used. These values " + "should be set as part of the LD_LIBRARY_PATH in the app master JVM " + "env using yarn.app.mapreduce.am.admin.user.env config settings."));
assertTrue(logMsg.contains("WARN - Usage of -Djava.library.path in " + "yarn.app.mapreduce.am.command-opts can cause programs to no longer " + "function if hadoop native libraries are used. These values should " + "be set as part of the LD_LIBRARY_PATH in the app master JVM env " + "using yarn.app.mapreduce.am.env config settings."));
}
use of org.apache.log4j.SimpleLayout in project ignite by apache.
the class GridNodeMetricsLogSelfTest method testNodeMetricsLog.
/**
* @throws Exception If failed.
*/
public void testNodeMetricsLog() throws Exception {
// Log to string, to check log content
Layout layout = new SimpleLayout();
StringWriter strWr = new StringWriter();
WriterAppender app = new WriterAppender(layout, strWr);
Logger.getRootLogger().addAppender(app);
Ignite g1 = startGrid(1);
IgniteCache<Integer, String> cache1 = g1.createCache("TestCache1");
cache1.put(1, "one");
Ignite g2 = startGrid(2);
IgniteCache<Integer, String> cache2 = g2.createCache("TestCache2");
cache2.put(2, "two");
Thread.sleep(10_000);
//Check that nodes are alie
assertEquals("one", cache1.get(1));
assertEquals("two", cache2.get(2));
String fullLog = strWr.toString();
Logger.getRootLogger().removeAppender(app);
assert fullLog.contains("Metrics for local node");
assert fullLog.contains("uptime=");
assert fullLog.contains("Non heap");
assert fullLog.contains("Outbound messages queue");
}
Aggregations