List of usage examples for org.apache.commons.logging LogFactory getLog
public static Log getLog(String name)
From source file:com.moss.appsnap.keeper.KeeperMain.java
public static void main(String[] args) throws Throwable { BasicConfigurator.resetConfiguration(); BasicConfigurator.configure();/*w w w.j a va 2s . co m*/ Log log = LogFactory.getLog(KeeperMain.class); try { new Keeper(new Url(args[0])); } catch (Throwable e) { log.error("Error launching keeper: " + e.getMessage(), e); throw e; } }
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 w w w. j ava2s . c o m*/ 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.mindquarry.management.user.UserManagementClient.java
public static void main(String[] args) { log = LogFactory.getLog(UserManagementClient.class); log.info("Starting user management client..."); //$NON-NLS-1$ // parse command line arguments CommandLine line = null;/* w w w. j a v a2 s.c om*/ CommandLineParser parser = new GnuParser(); try { // parse the command line arguments line = parser.parse(options, args); } catch (ParseException e) { // oops, something went wrong log.error("Parsing of command line failed."); //$NON-NLS-1$ printUsage(); return; } // retrieve login data System.out.print("Please enter your login ID: "); //$NON-NLS-1$ String user = readString(); user = user.trim(); System.out.print("Please enter your new password: "); //$NON-NLS-1$ String password = readString(); password = password.trim(); password = new String(DigestUtils.md5(password)); password = new String(Base64.encodeBase64(password.getBytes())); // start PWD change client UserManagementClient manager = new UserManagementClient(); try { if (line.hasOption(O_DEL)) { manager.deleteUser(line.getOptionValue(O_REPO), ADMIN_LOGIN, ADMIN_PWD, user, password); } else { manager.changePwd(line.getOptionValue(O_REPO), ADMIN_LOGIN, ADMIN_PWD, user, password); } } catch (Exception e) { log.error("Error while applying password changes.", e); //$NON-NLS-1$ } log.info("User management client finished successfully."); //$NON-NLS-1$ }
From source file:de.huberlin.wbi.cuneiform.cmdline.main.Main.java
public static void main(String[] args) throws IOException, ParseException, InterruptedException, NotDerivableException { CommandLine cmd;//ww w . j a va 2 s . c om Options opt; BaseRepl repl; BaseCreActor cre; Path sandbox; ExecutorService executor; TicketSrcActor ticketSrc; JsonSummary summary; Path summaryPath; Log statLog; int nthread; Path workDir; statLog = LogFactory.getLog("statLogger"); executor = Executors.newCachedThreadPool(); try { opt = getOptions(); cmd = parse(args, opt); config(cmd); if (cmd.hasOption('h')) { System.out.println("CUNEIFORM - A Functional Workflow Language\nversion " + BaseRepl.LABEL_VERSION + " build " + BaseRepl.LABEL_BUILD); new HelpFormatter().printHelp("java -jar cuneiform.jar [OPTION]*", opt); return; } if (cmd.hasOption('r')) Invocation.putLibPath(ForeignLambdaExpr.LANGID_R, cmd.getOptionValue('r')); if (cmd.hasOption('y')) Invocation.putLibPath(ForeignLambdaExpr.LANGID_PYTHON, cmd.getOptionValue('y')); if (cmd.hasOption('l')) sandbox = Paths.get(cmd.getOptionValue("l")); else sandbox = Paths.get(System.getProperty("user.home")).resolve(".cuneiform"); sandbox = sandbox.toAbsolutePath(); if (cmd.hasOption('c')) LocalThread.deleteIfExists(sandbox); if (cmd.hasOption('t')) nthread = Integer.valueOf(cmd.getOptionValue('t')); else nthread = Runtime.getRuntime().availableProcessors(); if (cmd.hasOption('w')) workDir = Paths.get(cmd.getOptionValue('w')); else workDir = Paths.get(System.getProperty("user.dir")); workDir = workDir.toAbsolutePath(); switch (platform) { case PLATFORM_LOCAL: if (!Files.exists(sandbox)) Files.createDirectories(sandbox); cre = new LocalCreActor(sandbox, workDir, nthread); break; case PLATFORM_HTCONDOR: if (!Files.exists(sandbox)) Files.createDirectories(sandbox); if (cmd.hasOption('m')) { // MAX_TRANSFER SIZE String maxTransferSize = cmd.getOptionValue('m'); try { cre = new CondorCreActor(sandbox, maxTransferSize); } catch (Exception e) { System.out.println("INVALID '-m' option value: " + maxTransferSize + "\n\nCUNEIFORM - A Functional Workflow Language\nversion " + BaseRepl.LABEL_VERSION + " build " + BaseRepl.LABEL_BUILD); new HelpFormatter().printHelp("java -jar cuneiform.jar [OPTION]*", opt); return; } } else { cre = new CondorCreActor(sandbox); } break; default: throw new RuntimeException("Platform not recognized."); } executor.submit(cre); ticketSrc = new TicketSrcActor(cre); executor.submit(ticketSrc); executor.shutdown(); switch (format) { case FORMAT_CF: if (cmd.hasOption("i")) repl = new InteractiveRepl(ticketSrc, statLog); else repl = new CmdlineRepl(ticketSrc, statLog); break; case FORMAT_DAX: repl = new DaxRepl(ticketSrc, statLog); break; default: throw new RuntimeException("Format not recognized."); } if (cmd.hasOption("i")) { // run in interactive mode BaseRepl.run(repl); return; } // run in quiet mode if (inputFileVector.length > 0) for (Path f : inputFileVector) repl.interpret(readFile(f)); else repl.interpret(readStdIn()); Thread.sleep(3 * Actor.DELAY); while (repl.isBusy()) Thread.sleep(Actor.DELAY); if (cmd.hasOption("s")) { summary = new JsonSummary(ticketSrc.getRunId(), sandbox, repl.getAns()); summaryPath = Paths.get(cmd.getOptionValue("s")); summaryPath = summaryPath.toAbsolutePath(); try (BufferedWriter writer = Files.newBufferedWriter(summaryPath, Charset.forName("UTF-8"))) { writer.write(summary.toString()); } } } finally { executor.shutdownNow(); } }
From source file:net.pandoragames.far.ui.swing.FindAndReplace.java
/** * The main method. Expects no arguments. * //w ww.ja v a 2s. c o m * @param args * not evaluated */ public static void main(String[] args) { if (FARConfig.getEffectiveJavaVersion() == 0) { // obscure jvm LogFactory.getLog(FindAndReplace.class) .warn("Java version could not be read. This may very well lead to unexpected crashes"); } else if (FARConfig.getEffectiveJavaVersion() < 5) { // won't work - // exit LogFactory.getLog(FindAndReplace.class) .error("FAR requires java 5 (1.5.x) or higher. Found 1." + FARConfig.getEffectiveJavaVersion()); System.exit(1); } else { LogFactory.getLog(FindAndReplace.class).debug("Running on java " + FARConfig.getEffectiveJavaVersion()); } JFrame.setDefaultLookAndFeelDecorated(SwingConfig.isMacOSX()); UIManager.put("Button.defaultButtonFollowsFocus", Boolean.TRUE); FindAndReplace far = new FindAndReplace(); far.configure(); far.init(); far.pack(); far.setVisible(true); // First time initialisation - speeds up the loading of the help views HelpView helpView = new HelpView(far, "About", "about.html", new Point(100, 100)); helpView.pack(); helpView.setVisible(false); if (args.length > 0 && SwingConfig.getEffectiveJavaVersion() > 5) { List<File> fileList = new ArrayList<File>(); for (String arg : args) { File file = new File(arg); if (file.exists()) fileList.add(file); } if (fileList.size() > 0) { far.fileImporter.importFiles(fileList); } } if (far.config.versionHasChanged()) { UpdateDialog updateWizzard = new UpdateDialog(far, far.config, far.componentRepository); if (updateWizzard.isUserInteractionRequired()) { updateWizzard.pack(); updateWizzard.setVisible(true); } else { updateWizzard.dispose(); } } }
From source file:com.mindquarry.jcr.change.ChangeClient.java
public static void main(String[] args) { log = LogFactory.getLog(ChangeClient.class); log.info("Starting persistence client..."); // parse command line arguments CommandLine line = null;/*from ww w .j av a 2s . c om*/ CommandLineParser parser = new GnuParser(); try { // parse the command line arguments line = parser.parse(options, args); } catch (ParseException e) { // oops, something went wrong log.error("Parsing of command line failed."); printUsage(); return; } // check debug option boolean debug = false; if (line.hasOption(O_DRY)) { log.info("Running in 'dry' mode."); debug = true; } // start change client ChangeClient cl = new ChangeClient(); try { cl.run(line.getOptionValue(O_REPO), line.getOptionValue(O_USER), line.getOptionValue(O_PWD), line.getOptionValue(O_XSLT), line.getOptionValue(O_FOLDER), debug); } catch (Exception e) { log.error("Error while applying changes.", e); } log.info("Changes applied."); }
From source file:com.winvector.logistic.demo.MapReduceScore.java
public static void main(final String[] args) throws Exception { final MapReduceScore mrl = new MapReduceScore(); final int code = ToolRunner.run(null, mrl, args); if (code != 0) { final Log log = LogFactory.getLog(MapReduceScore.class); log.fatal("MapReduceScore error, return code: " + code); ToolRunner.printGenericCommandUsage(System.out); }/* ww w . ja v a2s. c o m*/ }
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 {// w w w . jav a 2 s .co m 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.winvector.logistic.demo.MapReduceLogisticTrain.java
public static void main(final String[] args) throws Exception { final MapReduceLogisticTrain mrl = new MapReduceLogisticTrain(); final int code = ToolRunner.run(null, mrl, args); if (code != 0) { final Log log = LogFactory.getLog(MapReduceLogisticTrain.class); log.fatal("MapReduceLogistic error, return code: " + code); ToolRunner.printGenericCommandUsage(System.out); }// w w w . ja v a 2 s . co m }
From source file:com.microsoft.gittf.client.clc.Main.java
public static void main(String[] args) { // Configure logging, use the standard TFS SDK logging. System.setProperty("teamexplorer.application", ProductInformation.getProductName()); //$NON-NLS-1$ LoggingConfiguration.configure();/*from w ww. j av a 2s. c om*/ final Log log = LogFactory.getLog(ProductInformation.getProductName()); try { ArgumentCollection mainArguments = new ArgumentCollection(); try { mainArguments = ArgumentParser.parse(args, ARGUMENTS, ArgumentParserOptions.ALLOW_UNKNOWN_ARGUMENTS); } catch (ArgumentParserException e) { console.getErrorStream().println(e.getLocalizedMessage()); console.getErrorStream().println(getUsage()); System.exit(ExitCode.FAILURE); } if (mainArguments.contains("version")) //$NON-NLS-1$ { console.getOutputStream().println(Messages.formatString("Main.ApplicationVersionFormat", //$NON-NLS-1$ ProductInformation.getProductName(), ProductInformation.getBuildNumber())); return; } /* * Special case "--help command" handling - convert to * "help command" */ if (mainArguments.contains("help") && mainArguments.contains("command")) //$NON-NLS-1$ //$NON-NLS-2$ { HelpCommand helpCommand = new HelpCommand(); helpCommand.setArguments(ArgumentParser.parse(new String[] { ((FreeArgumentCollection) mainArguments.getArgument("command")).getValues()[0] //$NON-NLS-1$ }, helpCommand.getPossibleArguments())); helpCommand.setConsole(console); helpCommand.run(); return; } else if (mainArguments.contains("help") || !mainArguments.contains("command")) //$NON-NLS-1$ //$NON-NLS-2$ { showHelp(); return; } // Set the verbosity of the console from the arguments. if (mainArguments.contains("quiet")) //$NON-NLS-1$ { console.setVerbosity(Verbosity.QUIET); } else if (mainArguments.contains("verbose")) //$NON-NLS-1$ { console.setVerbosity(Verbosity.VERBOSE); } /* * Parse the free arguments into the command name and arguments to * pass to it. Add any unmatched arguments that were specified on * the command line before the argument. (eg, for * "git-tf --bare clone", we parsed the "--bare" as an unmatched * argument to the main command. We instead want to add the "--bare" * as an argument to "clone".) */ String[] fullCommand = ((FreeArgumentCollection) mainArguments.getArgument("command")).getValues(); //$NON-NLS-1$ String[] additionalArguments = mainArguments.getUnknownArguments(); String commandName = fullCommand[0]; String[] commandArgs = new String[additionalArguments.length + (fullCommand.length - 1)]; if (additionalArguments.length > 0) { System.arraycopy(additionalArguments, 0, commandArgs, 0, additionalArguments.length); } if (fullCommand.length > 1) { System.arraycopy(fullCommand, 1, commandArgs, mainArguments.getUnknownArguments().length, fullCommand.length - 1); } // Locate the specified command by name List<CommandDefinition> possibleCommands = new ArrayList<CommandDefinition>(); for (CommandDefinition c : COMMANDS) { if (c.getName().equals(commandName)) { possibleCommands.clear(); possibleCommands.add(c); break; } else if (c.getName().startsWith(commandName)) { possibleCommands.add(c); } } if (possibleCommands.size() == 0) { printError(Messages.formatString("Main.CommandNotFoundFormat", commandName, //$NON-NLS-1$ ProductInformation.getProductName())); System.exit(1); } if (possibleCommands.size() > 1) { printError(Messages.formatString("Main.AmbiguousCommandFormat", commandName, //$NON-NLS-1$ ProductInformation.getProductName())); for (CommandDefinition c : possibleCommands) { printError(Messages.formatString("Main.AmbiguousCommandListFormat", c.getName()), false); //$NON-NLS-1$ } System.exit(1); } // Instantiate the command final CommandDefinition commandDefinition = possibleCommands.get(0); Command command = null; try { command = commandDefinition.getType().newInstance(); } catch (Exception e) { printError(Messages.formatString("Main.CommandCreationFailedFormat", commandName)); //$NON-NLS-1$ System.exit(1); } // Set the console command.setConsole(console); // Parse the arguments ArgumentCollection argumentCollection = null; try { argumentCollection = ArgumentParser.parse(commandArgs, command.getPossibleArguments()); } catch (ArgumentParserException e) { Main.printError(e.getLocalizedMessage()); Main.printError(getUsage(command)); log.error("Could not parse arguments", e); //$NON-NLS-1$ System.exit(1); } // Handle the --help argument directly if (argumentCollection.contains("help")) //$NON-NLS-1$ { command.showHelp(); System.exit(0); } // Set the verbosity of the console from the arguments. if (argumentCollection.contains("quiet")) //$NON-NLS-1$ { console.setVerbosity(Verbosity.QUIET); } else if (argumentCollection.contains("verbose")) //$NON-NLS-1$ { console.setVerbosity(Verbosity.VERBOSE); } command.setArguments(argumentCollection); System.exit(command.run()); } catch (Exception e) { printError(e.getLocalizedMessage()); log.warn(MessageFormat.format("Error executing command: {0}", getCommandLine(args)), e); //$NON-NLS-1$ } }