Back Home

Scraping

Logging

Log4j async logger

    <?xml version="1.0" encoding="UTF-8"?>
        <configuration status="warn" name="MyApp" packages="">
        <appenders>
            <File name="MyFile" fileName="logs/app.log">
                <PatternLayout>
                    <pattern>%d %p %c{1.} [%t] %m%n</pattern>
                </PatternLayout>
            </File>
            <Async name="Async">
                <appender-ref ref="MyFile"/>
            </Async>
        </appenders>
        <loggers>
            <root level="error">
        <appender-ref ref="Async"/>
    </root>
 </loggers>
</configuration>

FailSafe

Command Line Options

import org.apache.commons.cli.BasicParser
import org.apache.commons.cli.CommandLine
import org.apache.commons.cli.CommandLineParser
import org.apache.commons.cli.DefaultParser
import org.apache.commons.cli.HelpFormatter
import org.apache.commons.cli.Options
 
/**
 * Created by rdono on 02/05/2017.
 */
class zipi {
 
     static void main (String [] args ) {
         // setup some Options object
         Options options = new Options();
         options.addOption("t", false, "display current time");
 
         // then parse the received requirements 
         CommandLineParser parser = new DefaultParser();
         CommandLine cmd = parser.parse(options, args);
 
         if (cmd.getOptions().size() == 0) {
             HelpFormatter formatter = new HelpFormatter();
             println(formatter.printHelp( "Bulk tool injector", options));
             return
         }
     }
 
}

Interactive text input can be got with http://text-io.beryx.org

Rest

To prevent Unirest logging the following configuration around cookies stops it

RequestConfig globalConfig = RequestConfig.custom()
.setCookieSpec(CookieSpecs.IGNORE_COOKIES).build();
 
HttpClient httpclient = HttpClients.custom().setDefaultRequestConfig(globalConfig).build();
Unirest.setHttpClient(httpclient);
 
java_libraries.txt · Last modified: 2017/11/22 01:06 by root
 
RSS - 200 © CrosswireDigitialMedia Ltd