Example usage for org.apache.commons.logging Log info

List of usage examples for org.apache.commons.logging Log info

Introduction

In this page you can find the example usage for org.apache.commons.logging Log info.

Prototype

void info(Object message);

Source Link

Document

Logs a message with info log level.

Usage

From source file:com.morty.podcast.writer.validation.StandardFileValidator.java

public static void main(String[] args) {
    //Process a directory without exclusion...
    Log m_logger = LogFactory.getLog(StandardFileValidator.class);
    m_logger.info("Starting Validator");

    if (args.length != 1)
        throw new NullPointerException("No directory specified");

    String fileToProcess = args[0];
    m_logger.info("Processing [" + fileToProcess + "]");
    StandardFileValidator sfv = new StandardFileValidator();
    sfv.setFolderToProcess(new File(fileToProcess));
    try {/*from   w  w w  .  j  av  a2 s  .c  om*/
        sfv.process();
        m_logger.info("Directory Valid");
    } catch (Exception ex) {
        m_logger.info("Directory InValid");
        m_logger.error("Error thrown", ex);
    }

    m_logger.info("Finished Validator");
}

From source file:com.qrmedia.commons.aspect.example.AdviceDemo.java

public static void main(String[] args) {
    Log log = LogFactory.getLog(AdviceDemo.class);

    AdvisedObject advisedObject = (AdvisedObject) new ClassPathXmlApplicationContext(CONTEXT_FILENAMES)
            .getBean("advisedBean");

    log.info("Calling a traced method...");
    advisedObject.tracedMethod("James Bond", 7, "License to Kill".getBytes());
    log.info("Calling a traced method that returns a result...");
    log.info("Result: " + advisedObject.resultReturningTracedMethod(6));
    log.info("Calling a profiled method...");
    advisedObject.profiledMethod();/*from ww  w .j  av  a2s  . c o  m*/
}

From source file:com.moss.posixfifosockets.LongTestRunner.java

public static void main(String[] args) throws Exception {
    Log log = LogFactory.getLog(LongTestRunner.class);

    BasicConfigurator.resetConfiguration();
    BasicConfigurator.configure();//from  www . j  a v  a2s  .  c  om
    Logger.getRootLogger().setLevel(Level.INFO);
    log.info("Setting up");
    TempDir temp = TempDir.create();
    log.info("Running from " + temp.getAbsolutePath());

    exec(temp, 15, new MixedTestClientFactory(CONCURRENT_TESTS_LENGTH, temp));
    exec(temp, 1, new MixedTestClientFactory(SERIAL_TESTS_LENGTH, temp));
    exec(temp, 15, new JavaClientFactory(CONCURRENT_TESTS_LENGTH));
    exec(temp, 1, new JavaClientFactory(SERIAL_TESTS_LENGTH));
    exec(temp, 15, new BashClientFactory(CONCURRENT_TESTS_LENGTH, temp));
    exec(temp, 1, new BashClientFactory(SERIAL_TESTS_LENGTH, temp));

    log.info("Tearing down");
    temp.deleteRecursively();

}

From source file:com.cladonia.security.signature.SignatureVerifier.java

public static void main(String[] args) throws Exception {
    org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory
            .getLog(SignatureGenerator.class.getName());

    log.info("**** Testing Signature Verification *****");

    javax.xml.parsers.DocumentBuilderFactory dbf = javax.xml.parsers.DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);//  w  w w.  j av  a2  s  .  c  o m
    dbf.setAttribute("http://xml.org/sax/features/namespaces", Boolean.TRUE);

    File f = new File("c:\\temp\\sigout.xml");
    javax.xml.parsers.DocumentBuilder db = dbf.newDocumentBuilder();
    org.w3c.dom.Document doc = db.parse(new java.io.FileInputStream(f));

    SignatureVerifier verifier = new SignatureVerifier(doc, XngrURLUtilities.getURLFromFile(f).toString());
    if (verifier.verify())
        System.out.println("Signature 1 - verification passed");
    else
        System.out.println("Signature 1 - verification failed");

    File f2 = new File("c:\\temp\\sigout2.xml");
    org.w3c.dom.Document doc2 = db.parse(new java.io.FileInputStream(f2));

    // Note the apache api requires that you pass in a base uri, the location where the 
    // signature file is fine, if you do not know this (i.e in the case where the signature
    // file has not been saved), then just pass in "file:", as it works!!
    SignatureVerifier verifier2 = new SignatureVerifier(doc2, "file:");
    if (verifier2.verify())
        System.out.println("Signature 2 - verification passed");
    else
        System.out.println("Signature 2 - verification failed");

    File f3 = new File("c:\\temp\\vordelsig.xml");
    org.w3c.dom.Document doc3 = db.parse(new java.io.FileInputStream(f3));
    SignatureVerifier verifier3 = new SignatureVerifier(doc3, XngrURLUtilities.getURLFromFile(f3).toString());
    if (verifier3.verify())
        System.out.println("Vordel Signature - verification passed");
    else
        System.out.println("Vordel Signature - verification failed");

    File f4 = new File("c:\\temp\\license.xml");
    org.w3c.dom.Document doc4 = db.parse(new java.io.FileInputStream(f4));
    SignatureVerifier verifier4 = new SignatureVerifier(doc4, XngrURLUtilities.getURLFromFile(f4).toString());
    if (verifier4.verify())
        System.out.println("License Signature - verification passed");
    else
        System.out.println("License Signature - verification failed");

}

From source file:com.twitlinks.Main.java

/**
 * @param args//  w  ww. ja v  a  2s .  c o m
 * @throws ParseException 
 * @throws org.apache.lucene.queryParser.ParseException 
 * @throws IOException 
 * @throws InterruptedException 
 */
public static void main(String[] args)
        throws ParseException, IOException, org.apache.lucene.queryParser.ParseException, InterruptedException {
    Log log = LogFactory.getLog(Main.class);

    Parser parser = new Parser(true, "dataset_2m");
    parser.start();

    Indexer indexer = new Indexer();
    indexer.start();
    while (true) {
        try {
            Thread.sleep(2000);
            log.info(parser.getLinesRead() + ":" + indexer.docCount + ":" + Buffer.documentQueue.size());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        if (!parser.isAlive() && Buffer.documentQueue.size() == 0) {
            log.info(parser.getLinesRead() + ":" + indexer.docCount + ":" + Buffer.documentQueue.size());
            indexer.stopIndexing();
            break;
        }
    }

    //Test the simple search, current text:fantastic
    SimpleSearcher searcher = new SimpleSearcher();
    searcher.searcher();
}

From source file:LoggingTrial.java

public static void main(String[] args) {
    Log log = LogFactory.getLog(LoggingTrial.class);
    System.out.println("The Log being used >>> " + log);

    Exception e = new Exception("A DUMMY EXCEPTION");
    if (log.isTraceEnabled()) {
        log.trace("TRACE TEST");
        log.trace("TRACE TEST", e);
    }//from   www  .j  a  v  a 2 s.  c  om
    if (log.isDebugEnabled()) {
        log.debug("DEBUG TEST");
        log.debug("DEBUG TEST", e);
    }

    if (log.isInfoEnabled()) {
        log.info("INFO TEST");
        log.info("INFO TEST", e);
    }
    if (log.isWarnEnabled()) {
        log.warn("WARN TEST");
        log.warn("WARN TEST", e);
    }

    if (log.isErrorEnabled()) {
        log.error("ERROR TEST");
        log.error("ERROR TEST", e);
    }

    if (log.isFatalEnabled()) {
        log.fatal("FATAL TEST");
        log.fatal("FATAL TEST", e);
    }
}

From source file:io.compgen.cgpipe.CGPipe.java

public static void main(String[] args) {
    String fname = null;/*from  w w w .ja va 2 s .co m*/
    String logFilename = null;
    String outputFilename = null;
    PrintStream outputStream = null;

    int verbosity = 0;
    boolean silent = false;
    boolean dryrun = false;
    boolean silenceStdErr = false;
    boolean showHelp = false;

    List<String> targets = new ArrayList<String>();
    Map<String, VarValue> confVals = new HashMap<String, VarValue>();

    String k = null;

    for (int i = 0; i < args.length; i++) {
        String arg = args[i];
        if (i == 0) {
            if (new File(arg).exists()) {
                fname = arg;
                silenceStdErr = true;
                continue;
            }
        } else if (args[i - 1].equals("-f")) {
            fname = arg;
            continue;
        } else if (args[i - 1].equals("-l")) {
            logFilename = arg;
            continue;
        } else if (args[i - 1].equals("-o")) {
            outputFilename = arg;
            continue;
        }

        if (arg.equals("-h") || arg.equals("-help") || arg.equals("--help")) {
            if (k != null) {
                if (k.contains("-")) {
                    k = k.replaceAll("-", "_");
                }
                confVals.put(k, VarBool.TRUE);
            }
            showHelp = true;
        } else if (arg.equals("-license")) {
            license();
            System.exit(1);
        } else if (arg.equals("-s")) {
            if (k != null) {
                if (k.contains("-")) {
                    k = k.replaceAll("-", "_");
                }
                confVals.put(k, VarBool.TRUE);
            }
            silent = true;
        } else if (arg.equals("-nolog")) {
            if (k != null) {
                if (k.contains("-")) {
                    k = k.replaceAll("-", "_");
                }
                confVals.put(k, VarBool.TRUE);
            }
            silenceStdErr = true;
        } else if (arg.equals("-v")) {
            if (k != null) {
                if (k.contains("-")) {
                    k = k.replaceAll("-", "_");
                }
                confVals.put(k, VarBool.TRUE);
            }
            verbosity++;
        } else if (arg.equals("-vv")) {
            if (k != null) {
                if (k.contains("-")) {
                    k = k.replaceAll("-", "_");
                }
                confVals.put(k, VarBool.TRUE);
            }
            verbosity += 2;
        } else if (arg.equals("-vvv")) {
            if (k != null) {
                if (k.contains("-")) {
                    k = k.replaceAll("-", "_");
                }
                confVals.put(k, VarBool.TRUE);
            }
            verbosity += 3;
        } else if (arg.equals("-dr")) {
            if (k != null) {
                if (k.contains("-")) {
                    k = k.replaceAll("-", "_");
                }
                confVals.put(k, VarBool.TRUE);
            }
            dryrun = true;
        } else if (arg.startsWith("--")) {
            if (k != null) {
                if (k.contains("-")) {
                    k = k.replaceAll("-", "_");
                }
                confVals.put(k, VarBool.TRUE);
            }
            k = arg.substring(2);
        } else if (k != null) {
            if (k.contains("-")) {
                k = k.replaceAll("-", "_");
            }
            if (confVals.containsKey(k)) {
                try {
                    VarValue val = confVals.get(k);
                    if (val.getClass().equals(VarList.class)) {
                        ((VarList) val).add(VarValue.parseStringRaw(arg));
                    } else {
                        VarList list = new VarList();
                        list.add(val);
                        list.add(VarValue.parseStringRaw(arg));
                        confVals.put(k, list);
                    }
                } catch (VarTypeException e) {
                    System.err.println("Error setting variable: " + k + " => " + arg);
                    System.exit(1);
                    ;
                }
            } else {
                confVals.put(k, VarValue.parseStringRaw(arg));
            }
            k = null;
        } else if (arg.charAt(0) != '-') {
            targets.add(arg);
        }
    }
    if (k != null) {
        if (k.contains("-")) {
            k = k.replaceAll("-", "_");
        }
        confVals.put(k, VarBool.TRUE);
    }

    confVals.put("cgpipe.loglevel", new VarInt(verbosity));

    if (fname == null) {
        usage();
        System.exit(1);
    }

    if (!showHelp) {
        switch (verbosity) {
        case 0:
            SimpleFileLoggerImpl.setLevel(Level.INFO);
            break;
        case 1:
            SimpleFileLoggerImpl.setLevel(Level.DEBUG);
            break;
        case 2:
            SimpleFileLoggerImpl.setLevel(Level.TRACE);
            break;
        case 3:
        default:
            SimpleFileLoggerImpl.setLevel(Level.ALL);
            break;
        }
    } else {
        SimpleFileLoggerImpl.setLevel(Level.FATAL);
    }

    SimpleFileLoggerImpl.setSilent(silenceStdErr || showHelp);

    Log log = LogFactory.getLog(CGPipe.class);
    log.info("Starting new run: " + fname);

    if (logFilename != null) {
        confVals.put("cgpipe.log", new VarString(logFilename));
    }

    if (System.getenv("CGPIPE_DRYRUN") != null && !System.getenv("CGPIPE_DRYRUN").equals("")) {
        dryrun = true;
    }

    JobRunner runner = null;
    try {
        // Load config values from global config. 
        RootContext root = new RootContext();
        loadInitFiles(root);

        // Load settings from environment variables.
        root.loadEnvironment();

        // Set cmd-line arguments
        if (silent) {
            root.setOutputStream(null);
        }

        if (outputFilename != null) {
            outputStream = new PrintStream(new FileOutputStream(outputFilename));
            root.setOutputStream(outputStream);
        }

        for (String k1 : confVals.keySet()) {
            log.info("config: " + k1 + " => " + confVals.get(k1).toString());
        }

        root.update(confVals);
        root.set("cgpipe.procs", new VarInt(Runtime.getRuntime().availableProcessors()));

        // update the URL Source loader configs
        SourceLoader.updateRemoteHandlers(root.cloneString("cgpipe.remote"));

        // Now check for help, only after we've setup the remote handlers...
        if (showHelp) {
            try {
                Parser.showHelp(fname);
                System.exit(0);
            } catch (IOException e) {
                System.err.println("Unable to find pipeline: " + fname);
                System.exit(1);
            }
        }

        // Set the global config values
        //         globalConfig.putAll(root.cloneValues());

        // Parse the AST and run it
        Parser.exec(fname, root);

        // Load the job runner *after* we execute the script to capture any config changes
        runner = JobRunner.load(root, dryrun);

        // find a build-target, and submit the job(s) to a runner
        if (targets.size() > 0) {
            for (String target : targets) {
                log.debug("building: " + target);

                BuildTarget initTarget = root.build(target);
                if (initTarget != null) {
                    runner.submitAll(initTarget, root);
                } else {
                    System.out.println("CGPIPE ERROR: Unable to find target: " + target);
                }
            }
        } else {
            BuildTarget initTarget = root.build();
            if (initTarget != null) {
                runner.submitAll(initTarget, root);
                // Leave this commented out - it should be allowed to run cgpipe scripts w/o a target defined (testing)
                //            } else {
                //               System.out.println("CGPIPE ERROR: Unable to find default target");
            }
        }
        runner.done();

        if (outputStream != null) {
            outputStream.close();
        }

    } catch (ASTParseException | ASTExecException | RunnerException | FileNotFoundException e) {
        if (outputStream != null) {
            outputStream.close();
        }
        if (runner != null) {
            runner.abort();
        }

        if (e.getClass().equals(ExitException.class)) {
            System.exit(((ExitException) e).getReturnCode());
        }

        System.out.println("CGPIPE ERROR " + e.getMessage());
        if (verbosity > 0) {
            e.printStackTrace();
        }
        System.exit(1);
    }
}

From source file:com.cladonia.security.signature.SignatureGenerator.java

public static void main(String args[]) throws Exception {
    // use this if you want to configure logging, normally would put this in a static block, 
    // but this is just for testing (see jre\lib\logging.properties)
    org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory
            .getLog(SignatureGenerator.class.getName());

    //System.out.println("Using the logger: "+log.getClass().getName());  

    //log.debug("Debug is on");
    //log.warn("Warning is on");
    //log.error("Error is on");
    log.info("**** Testing Signature Generator *****");

    //All the parameters for the keystore
    String keystoreType = "JKS";
    String keystoreFile = "data/keystore.jks";
    String keystorePass = "xmlexchanger";
    String privateKeyAlias = "exchanger";
    String privateKeyPass = "xmlexchanger";
    String certificateAlias = "exchanger";

    // set the keystore and private key properties
    KeyBuilder.setParams(keystoreType, keystoreFile, keystorePass, privateKeyAlias, privateKeyPass,
            certificateAlias);//from ww  w . j  a va 2s  . co m

    // get the private key for signing.
    PrivateKey privateKey = KeyBuilder.getPrivateKey();

    // get the cert
    X509Certificate cert = KeyBuilder.getCertificate();

    // ************* create a sample to be signed ******************
    javax.xml.parsers.DocumentBuilderFactory dbf = javax.xml.parsers.DocumentBuilderFactory.newInstance();

    //XML Signature needs to be namespace aware
    dbf.setNamespaceAware(true);

    javax.xml.parsers.DocumentBuilder db = dbf.newDocumentBuilder();
    org.w3c.dom.Document document = db.newDocument();

    //Build a sample document. It will look something like:
    //<!-- Comment before -->
    //<cladonia:Exchanger xmlns:cladonia="http://www.exchangerxml.com">
    //</cladonia:Exchanger>

    document.appendChild(document.createComment(" Comment before "));
    Element root = document.createElementNS("http://www.exchangerxml.com", "cladonia:Exchanger");
    root.setAttributeNS(null, "attr1", "test1");
    root.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:foo", "http://www.exchangerxml.com/#foo");
    root.setAttributeNS("http://example.org/#foo", "foo:attr1", "foo's test");
    root.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:cladonia", "http://www.exchangerxml.com");
    document.appendChild(root);
    Element firstchild = document.createElementNS("http://www.exchangerxml.com", "cladonia:Editor");
    firstchild.appendChild(document.createTextNode("simple text\n"));
    firstchild.setAttributeNS(null, "Id", "CladoniaId");
    root.appendChild(firstchild);
    //******************** End of sample to be signed*************************

    // *************** Signature 1
    // create SignatureGenerator using private key, cert and the dom (i.e an enveloped signature)
    SignatureGenerator gen = new SignatureGenerator(privateKey, cert, document);

    // set the c14n algorithm (Exclusive)
    gen.setC14nAlgorithm(SignatureGenerator.TRANSFORM_C14N_EXCL_WITH_COMMENTS);

    // set the xpath transform
    gen.setXpath("//cladonia:Editor");

    // set the id
    gen.setId("CladoniaId");

    // sign the document
    document = gen.sign(null);

    // output the enveloped signature
    FileOutputStream fos = new FileOutputStream("c:\\temp\\sigout.xml");
    XMLUtils.outputDOMc14nWithComments(document, fos);
    fos.close();

    System.out.println("Created Signature 1 - an enveloped signature");

    // ************** Signature 2
    // now sign the previous output as an example of a detached signature
    SignatureGenerator gen2 = new SignatureGenerator(privateKey, cert, "file:///c:/temp/sigout.xml");

    // set the c14n algorithm
    gen2.setC14nAlgorithm(SignatureGenerator.TRANSFORM_C14N_WITH_COMMENTS);

    // sign the document
    Document document2 = gen2.sign(null);

    // output the detached signature
    FileOutputStream fos2 = new FileOutputStream("c:\\temp\\sigout2.xml");
    XMLUtils.outputDOMc14nWithComments(document2, fos2);
    fos2.close();

    System.out.println("Created Signature 2 - a detached signature");
    System.out.println("");
}

From source file:com.rodaxsoft.mailgun.example.Main.java

public static void main(String[] args) {
    Log log = LogFactory.getLog(Main.class);

    final Client client = ClientBuilder.newClient();

    HttpAuthenticationFeature authFeature;
    authFeature = HttpAuthenticationFeature.basicBuilder().nonPreemptive()
            .credentials("api", "key-3ax6xnjp29jd6fds4gc373sgvjxteol0").build();
    client.register(authFeature);//from   w w w  . j a  va 2s.c o  m

    WebTarget webTarget = client.target("https://api.mailgun.net/v2/samples.mailgun.org").path("messages");

    Form form = new Form();
    form.param("to", "john@example.com");
    form.param("from", "noreply@example.com");
    form.param("subject", "Hello World");
    form.param("text", "This is my first Mailgun email from Java");
    //Set the Reply-TO header
    form.param("h:Reply-To", "support@example.com");

    Invocation.Builder invocationBuilder;
    invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON_TYPE);
    Response response = invocationBuilder.post(Entity.form(form));
    int status = response.getStatus();
    log.info("status = " + status);

    if (response.hasEntity()) {
        String json = response.readEntity(String.class);
        log.info("entity = " + json);
    }
}

From source file:com.microsoft.tfs.client.clc.vc.Main.java

public static void main(final String[] args) {
    TELoggingConfiguration.configure();/*w  w  w . ja va 2 s .c  o m*/

    final Log log = LogFactory.getLog(Main.class);
    log.debug("Entering Main"); //$NON-NLS-1$
    Thread.currentThread().setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
        @Override
        public void uncaughtException(final Thread t, final Throwable e) {
            log.error("Unhandled exception in the thread " + t.getName() + " : ", e); //$NON-NLS-1$ //$NON-NLS-2$
            /*
             * Let the shutdown manager clean up any registered items.
             */
            try {
                log.debug("Shutting down"); //$NON-NLS-1$
                ShutdownManager.getInstance().shutdown();
                log.debug("Has shut down"); //$NON-NLS-1$
            } catch (final Exception ex) {
                log.error("Unhandled exception during shutdown: ", ex); //$NON-NLS-1$
            }
        }
    });
    /*
     * Please don't do any fancy work in this method, because we have a CLC
     * test harness that calls Main.run() directly, and we can't test
     * functionality in this method (because this method can't return a
     * status code but exits the process directly, which kind of hoses any
     * test framework).
     */

    final Main main = new Main();
    int ret = ExitCode.FAILURE;

    try {
        ret = main.run(args);
    } catch (final Throwable e) {
        log.error("Unhandled exception reached Main: ", e); //$NON-NLS-1$
    } finally {
        /*
         * Let the shutdown manager clean up any registered items.
         */
        try {
            log.info("Shutting down"); //$NON-NLS-1$
            ShutdownManager.getInstance().shutdown();
            log.info("Has shut down"); //$NON-NLS-1$
        } catch (final Exception e) {
            log.error("Unhandled exception during shutdown: ", e); //$NON-NLS-1$
        }
    }

    System.exit(ret);
}