Search in sources :

Example 46 with StreamHandler

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);
}
Also used : StreamHandler(java.util.logging.StreamHandler)

Example 47 with StreamHandler

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;
    }
}
Also used : PrintStream(java.io.PrintStream) HighTemporalResolutionFormatter(com.ms.silverking.log.HighTemporalResolutionFormatter) HighTemporalResolutionFormatter(com.ms.silverking.log.HighTemporalResolutionFormatter) Formatter(java.util.logging.Formatter) StreamHandler(java.util.logging.StreamHandler) File(java.io.File)

Example 48 with StreamHandler

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);
}
Also used : LogRecord(java.util.logging.LogRecord) Formatter(java.util.logging.Formatter) StreamHandler(java.util.logging.StreamHandler) CommandHandler(org.apache.ignite.internal.commandline.CommandHandler) Logger(java.util.logging.Logger) GridAbstractTest(org.apache.ignite.testframework.junits.GridAbstractTest) Test(org.junit.Test)

Example 49 with StreamHandler

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;
}
Also used : SimpleFormatter(java.util.logging.SimpleFormatter) StreamHandler(java.util.logging.StreamHandler) Logger(java.util.logging.Logger)

Example 50 with StreamHandler

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();
}
Also used : StreamHandler(java.util.logging.StreamHandler)

Aggregations

StreamHandler (java.util.logging.StreamHandler)51 ByteArrayOutputStream (java.io.ByteArrayOutputStream)28 LogRecord (java.util.logging.LogRecord)17 SimpleFormatter (java.util.logging.SimpleFormatter)16 Logger (java.util.logging.Logger)12 Properties (java.util.Properties)7 MockResponse (com.google.mockwebserver.MockResponse)6 HttpClient (org.apache.http.client.HttpClient)6 HttpGet (org.apache.http.client.methods.HttpGet)6 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)6 Formatter (java.util.logging.Formatter)3 Handler (java.util.logging.Handler)3 PrintStream (java.io.PrintStream)2 CommandHandler (org.apache.ignite.internal.commandline.CommandHandler)2 Before (org.junit.Before)2 Test (org.junit.Test)2 CommandRunner (com.google.copybara.util.CommandRunner)1 HighTemporalResolutionFormatter (com.ms.silverking.log.HighTemporalResolutionFormatter)1 XMLEncoder (java.beans.XMLEncoder)1 File (java.io.File)1