List of usage examples for java.lang System setErr
public static void setErr(PrintStream err)
From source file:org.uimafit.testing.util.HideOutput.java
/** * this method restores System.out and System.err */// w w w .j a va 2s . c om public void restoreOutput() { System.setOut(this.out); System.setErr(this.err); }
From source file:org.eclipse.jetty.demo.Main.java
private static void defLogging() throws java.io.IOException { org.eclipse.jetty.util.log.Log.setLog(new org.eclipse.jetty.util.log.StdErrLog()); RolloverFileOutputStream rfos = new RolloverFileOutputStream( System.getProperty("user.dir") + "\\log\\jetty_yyyy_mm_dd.log", true); TeeOutputStream myOut = new TeeOutputStream(System.out, rfos); PrintStream ps = new PrintStream(myOut); System.setOut(ps);//w ww. j av a 2 s. com System.setErr(ps); }
From source file:edu.rit.flick.util.FlickTest.java
@AfterClass public static void cleanUpStreams() throws IOException { outContent.close();// ww w. j ava2 s. co m errContent.close(); System.setOut(oldOut); System.setErr(oldErr); }
From source file:com.music.service.text.SentimentAnalyzer.java
@PostConstruct public void init() { // because scientists can't code, and write debug messages to System.err PrintStream err = new PrintStream(System.err) { @Override//from w w w . j av a 2s . co m public void println(String x) { if (!x.startsWith("Adding annotator")) { super.println(x); } } }; System.setErr(err); }
From source file:org.who.canreg.dbprocessor.utils.LogManager.java
private LogManager() throws IOException { //Create the "Logs" folder (or locate it, if it's existent). debugLogFile = new File("Logs"); //runtimeExceptionsLogFile = new File("Logs"); //We delete the directory if there are more than 50 log files inside if (debugLogFile.exists()) { if (debugLogFile.list().length >= 50) FileUtils.cleanDirectory(debugLogFile); } else/*from w ww . j av a2 s . co m*/ debugLogFile.mkdirs(); debugLogFile = new File(debugLogFile, "Log " + Utils.getCurrentTime2() + ".txt"); debug = new PrintStream(debugLogFile); if (AppContext.productionBuild) System.setErr(debug); //************DEPRECATED*************// //runtimeExceptionsLogFile = new File(runtimeExceptionsLogFile, "Error Log " + Utils.getCurrentTime2() + ".txt"); //We log unchecked/runtime errors in a file //System.setErr(new PrintStream(runtimeExceptionsLogFile)); //************DEPRECATED*************// }
From source file:cpd3314.project.CPD3314ProjectTest.java
@Before public void setUp() { outContent = new ByteArrayOutputStream(); errContent = new ByteArrayOutputStream(); System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); }
From source file:org.drugis.addis.gui.GUIFactory.java
public static void suppressErrors(boolean suppress) { if (suppress) { System.setErr(new PrintStream(new OutputStream() { // suppress system.err output public void write(int b) { }/*from www . j av a2 s . c o m*/ })); } else { System.setErr(s_errorStream); // reset system.err output } }
From source file:CraftAPI.java
/** * Construct the object.//from w w w. j a va 2 s .c o m */ public CraftAPI() { eventDispatcher = new EventDispatcher(); listener = new CraftAPIListener(eventDispatcher); try { System.setOut(new PrintStream(new CopyingEventOuputStream(System.out, eventDispatcher))); System.setErr(new PrintStream(new CopyingEventOuputStream(System.err, eventDispatcher))); // Logger.GLOBAL_LOGGER_NAME doesn't seem to work Logger.getLogger("Minecraft").addHandler(new LoggingEventHandler(eventDispatcher, new LogFormat())); } catch (Throwable t) { logger.log(Level.WARNING, "CraftAPI: Could not redirect stdout/stderr"); t.printStackTrace(); } }
From source file:org.apache.hadoop.gateway.util.KnoxCLITest.java
@Before public void setup() throws Exception { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); }
From source file:org.apache.hadoop.hbase.backup.TestBackupDescribe.java
/** * Verify that describe works as expected if incorrect backup Id is supplied * @throws Exception/*w ww.j a v a2 s . com*/ */ @Test public void testBackupDescribe() throws Exception { LOG.info("test backup describe on a single table with data"); String[] args = new String[] { "describe", "backup_2" }; int ret = ToolRunner.run(conf1, new BackupDriver(), args); assertTrue(ret < 0); ByteArrayOutputStream baos = new ByteArrayOutputStream(); System.setErr(new PrintStream(baos)); args = new String[] { "progress" }; ToolRunner.run(TEST_UTIL.getConfiguration(), new BackupDriver(), args); String output = baos.toString(); LOG.info("Output from progress: " + output); assertTrue(output.indexOf(BackupCommands.NO_ACTIVE_SESSION_FOUND) >= 0); }