use of java.util.logging.StreamHandler in project SilverKing by Morgan-Stanley.
the class JavaLogDest method setPrintStreams.
public void setPrintStreams(OutputStream out) {
setErrPrintStream(out);
setOutPrintStream(out);
logger.removeHandler(handler);
handler = new StreamHandler(out, formatter);
logger.addHandler(handler);
}
use of java.util.logging.StreamHandler in project SilverKing by Morgan-Stanley.
the class TerminatorAsyncLogger method getLogger.
private Logger getLogger() throws FileNotFoundException {
synchronized (this) {
// not really needed yet, but TerminatorAsyncLogger is exposed to more than one thread
if (log == null) {
PrintStream ps = new PrintStream(new File(logFileName));
log = Logger.getLogger(argusLoggerName);
Formatter formatter = new HighTemporalResolutionFormatter();
handler = new StreamHandler(ps, formatter);
log.addHandler(handler);
log.setLevel(Level.ALL);
}
return log;
}
}
use of java.util.logging.StreamHandler in project ignite by apache.
the class GridCommandHandlerClusterByClassTest method testErrUnexpectedWithWithoutVerbose.
/**
* Test checks that stack trace for unexpected error will be output with or
* without {@link CommonArgParser#CMD_VERBOSE} flag.
*/
@Test
public void testErrUnexpectedWithWithoutVerbose() {
injectTestSystemOut();
Logger log = CommandHandler.initLogger(null);
log.addHandler(new StreamHandler(System.out, new Formatter() {
/**
* {@inheritDoc}
*/
@Override
public String format(LogRecord record) {
String msg = record.getMessage();
if (msg.contains("Cluster state:"))
throw new Error();
return msg + "\n";
}
}));
int resCode = EXIT_CODE_UNEXPECTED_ERROR;
CommandHandler cmd = new CommandHandler(log);
assertEquals(resCode, execute(cmd, BASELINE.text()));
assertContains(GridAbstractTest.log, testOut.toString(), ERROR_STACK_TRACE_PREFIX);
assertEquals(resCode, execute(cmd, BASELINE.text(), CMD_VERBOSE));
assertContains(GridAbstractTest.log, testOut.toString(), ERROR_STACK_TRACE_PREFIX);
}
use of java.util.logging.StreamHandler in project jreversepro by akkumar.
the class CustomLoggerFactory method createLogger.
public static Logger createLogger() {
final Logger logger = Logger.getLogger("JReversePro");
final SimpleFormatter formatter = new SimpleFormatter();
final StreamHandler handler = new StreamHandler(System.out, formatter);
logger.addHandler(handler);
logger.setLevel(Level.FINER);
return logger;
}
use of java.util.logging.StreamHandler in project j2objc by google.
the class OldFormatterTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
h = new StreamHandler();
}
Aggregations