Search in sources :

Example 41 with SimpleFormatter

use of java.util.logging.SimpleFormatter in project jgnash by ccavanaugh.

the class OfxV2Parser method enableDetailedLogFile.

static void enableDetailedLogFile() {
    try {
        final Handler fh = new FileHandler("%h/jgnash-ofx.log", false);
        fh.setFormatter(new SimpleFormatter());
        logger.addHandler(fh);
        logger.setLevel(Level.ALL);
    } catch (final IOException ioe) {
        logger.severe(ResourceUtils.getString("Message.Error.LogFileHandler"));
    }
}
Also used : SimpleFormatter(java.util.logging.SimpleFormatter) FileHandler(java.util.logging.FileHandler) Handler(java.util.logging.Handler) IOException(java.io.IOException) FileHandler(java.util.logging.FileHandler)

Example 42 with SimpleFormatter

use of java.util.logging.SimpleFormatter in project pyramid by cheng-li.

the class App3 method main.

public static void main(String[] args) throws Exception {
    if (args.length != 1) {
        throw new IllegalArgumentException("Please specify a properties file.");
    }
    Config config = new Config(args[0]);
    Logger logger = Logger.getAnonymousLogger();
    String logFile = config.getString("output.log");
    FileHandler fileHandler = null;
    if (!logFile.isEmpty()) {
        new File(logFile).getParentFile().mkdirs();
        //todo should append?
        fileHandler = new FileHandler(logFile, true);
        java.util.logging.Formatter formatter = new SimpleFormatter();
        fileHandler.setFormatter(formatter);
        logger.addHandler(fileHandler);
        logger.setUseParentHandlers(false);
    }
    logger.info(config.toString());
    if (fileHandler != null) {
        fileHandler.close();
    }
    File output = new File(config.getString("output.folder"));
    output.mkdirs();
    Config app1Config = createApp1Config(config);
    Config app2Config = createApp2Config(config);
    App1.main(app1Config);
    App2.main(app2Config);
}
Also used : Config(edu.neu.ccs.pyramid.configuration.Config) SimpleFormatter(java.util.logging.SimpleFormatter) Logger(java.util.logging.Logger) File(java.io.File) FileHandler(java.util.logging.FileHandler)

Aggregations

SimpleFormatter (java.util.logging.SimpleFormatter)42 StreamHandler (java.util.logging.StreamHandler)15 ByteArrayOutputStream (java.io.ByteArrayOutputStream)13 Logger (java.util.logging.Logger)13 FileHandler (java.util.logging.FileHandler)11 Handler (java.util.logging.Handler)8 LogRecord (java.util.logging.LogRecord)8 IOException (java.io.IOException)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 ConsoleHandler (java.util.logging.ConsoleHandler)4 File (java.io.File)3 Level (java.util.logging.Level)3 Test (org.junit.Test)3 Config (edu.neu.ccs.pyramid.configuration.Config)2 Properties (java.util.Properties)2 Formatter (java.util.logging.Formatter)2 MemoryHandler (java.util.logging.MemoryHandler)2