List of usage examples for org.apache.commons.logging Log debug
void debug(Object message);
From source file:com.microsoft.tfs.client.clc.vc.Main.java
public static void main(final String[] args) { TELoggingConfiguration.configure();/* ww w . j av a 2 s. co 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); }
From source file:it.doqui.index.ecmengine.test.AllTests.java
public static void main(String[] args) { Log logger = LogFactory.getLog(ECMENGINE_TEST_LOG_CATEGORY); logger.debug("[AllTests::main] BEGIN"); String runner;/*from w w w. j a va 2 s. co m*/ int i; String arguments[]; Class cls; runner = null; for (i = 0; (i < args.length) && (null == runner); i++) { if (args[i].equalsIgnoreCase("-text")) runner = "junit.textui.TestRunner"; else if (args[i].equalsIgnoreCase("-awt")) runner = "junit.awtui.TestRunner"; else if (args[i].equalsIgnoreCase("-swing")) runner = "junit.swingui.TestRunner"; } if (null != runner) { // remove it from the arguments arguments = new String[args.length - 1]; System.arraycopy(args, 0, arguments, 0, i - 1); System.arraycopy(args, i, arguments, i - 1, args.length - i); args = arguments; } else runner = "junit.swingui.TestRunner"; // append the test class arguments = new String[args.length + 1]; System.arraycopy(args, 0, arguments, 0, args.length); arguments[args.length] = "it.doqui.index.ecmengine.test.AllTests"; // invoke main() of the test runner try { cls = Class.forName(runner); java.lang.reflect.Method method = cls.getDeclaredMethod("main", new Class[] { String[].class }); method.invoke(null, new Object[] { arguments }); } catch (Throwable t) { logger.debug("[AllTests::main] Problem in test execution : " + t); } finally { logger.debug("[AllTests::main] BEGIN"); } }
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 ww w. j a v a2s . co m*/ 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:net.sf.mcf2pdf.Main.java
@SuppressWarnings("static-access") public static void main(String[] args) { Options options = new Options(); Option o = OptionBuilder.hasArg().isRequired() .withDescription("Installation location of My CEWE Photobook. REQUIRED.").create('i'); options.addOption(o);/* w w w. j av a 2s. com*/ options.addOption("h", false, "Prints this help and exits."); options.addOption("t", true, "Location of MCF temporary files."); options.addOption("w", true, "Location for temporary images generated during conversion."); options.addOption("r", true, "Sets the resolution to use for page rendering, in DPI. Default is 150."); options.addOption("n", true, "Sets the page number to render up to. Default renders all pages."); options.addOption("b", false, "Prevents rendering of binding between double pages."); options.addOption("x", false, "Generates only XSL-FO content instead of PDF content."); options.addOption("q", false, "Quiet mode - only errors are logged."); options.addOption("d", false, "Enables debugging logging output."); CommandLine cl; try { CommandLineParser parser = new PosixParser(); cl = parser.parse(options, args); } catch (ParseException pe) { printUsage(options, pe); System.exit(3); return; } if (cl.hasOption("h")) { printUsage(options, null); return; } if (cl.getArgs().length != 2) { printUsage(options, new ParseException("INFILE and OUTFILE must be specified. Arguments were: " + cl.getArgList())); System.exit(3); return; } File installDir = new File(cl.getOptionValue("i")); if (!installDir.isDirectory()) { printUsage(options, new ParseException("Specified installation directory does not exist.")); System.exit(3); return; } File tempDir = null; String sTempDir = cl.getOptionValue("t"); if (sTempDir == null) { tempDir = new File(new File(System.getProperty("user.home")), ".mcf"); if (!tempDir.isDirectory()) { printUsage(options, new ParseException("MCF temporary location not specified and default location " + tempDir + " does not exist.")); System.exit(3); return; } } else { tempDir = new File(sTempDir); if (!tempDir.isDirectory()) { printUsage(options, new ParseException("Specified temporary location does not exist.")); System.exit(3); return; } } File mcfFile = new File(cl.getArgs()[0]); if (!mcfFile.isFile()) { printUsage(options, new ParseException("MCF input file does not exist.")); System.exit(3); return; } mcfFile = mcfFile.getAbsoluteFile(); File tempImages = new File(new File(System.getProperty("user.home")), ".mcf2pdf"); if (cl.hasOption("w")) { tempImages = new File(cl.getOptionValue("w")); if (!tempImages.mkdirs() && !tempImages.isDirectory()) { printUsage(options, new ParseException("Specified working dir does not exist and could not be created.")); System.exit(3); return; } } int dpi = 150; if (cl.hasOption("r")) { try { dpi = Integer.valueOf(cl.getOptionValue("r")).intValue(); if (dpi < 30 || dpi > 600) throw new IllegalArgumentException(); } catch (Exception e) { printUsage(options, new ParseException("Parameter for option -r must be an integer between 30 and 600.")); } } int maxPageNo = -1; if (cl.hasOption("n")) { try { maxPageNo = Integer.valueOf(cl.getOptionValue("n")).intValue(); if (maxPageNo < 0) throw new IllegalArgumentException(); } catch (Exception e) { printUsage(options, new ParseException("Parameter for option -n must be an integer >= 0.")); } } boolean binding = true; if (cl.hasOption("b")) { binding = false; } OutputStream finalOut; if (cl.getArgs()[1].equals("-")) finalOut = System.out; else { try { finalOut = new FileOutputStream(cl.getArgs()[1]); } catch (IOException e) { printUsage(options, new ParseException("Output file could not be created.")); System.exit(3); return; } } // configure logging, if no system property is present if (System.getProperty("log4j.configuration") == null) { PropertyConfigurator.configure(Main.class.getClassLoader().getResource("log4j.properties")); Logger.getRootLogger().setLevel(Level.INFO); if (cl.hasOption("q")) Logger.getRootLogger().setLevel(Level.ERROR); if (cl.hasOption("d")) Logger.getRootLogger().setLevel(Level.DEBUG); } // start conversion to XSL-FO // if -x is specified, this is the only thing we do OutputStream xslFoOut; if (cl.hasOption("x")) xslFoOut = finalOut; else xslFoOut = new ByteArrayOutputStream(); Log log = LogFactory.getLog(Main.class); try { new Mcf2FoConverter(installDir, tempDir, tempImages).convert(mcfFile, xslFoOut, dpi, binding, maxPageNo); xslFoOut.flush(); if (!cl.hasOption("x")) { // convert to PDF log.debug("Converting XSL-FO data to PDF"); byte[] data = ((ByteArrayOutputStream) xslFoOut).toByteArray(); PdfUtil.convertFO2PDF(new ByteArrayInputStream(data), finalOut, dpi); finalOut.flush(); } } catch (Exception e) { log.error("An exception has occured", e); System.exit(1); return; } finally { if (finalOut instanceof FileOutputStream) { try { finalOut.close(); } catch (Exception e) { } } } }
From source file:com.moss.veracity.core.Veracity.java
public static void main(String[] args) throws Exception { File log4jConfigFile = new File("log4j.xml"); if (log4jConfigFile.exists()) { DOMConfigurator.configureAndWatch(log4jConfigFile.getAbsolutePath(), 1000); }/*from ww w . ja va 2 s . c o m*/ final Log log = LogFactory.getLog(Veracity.class); File homeDir = new File(System.getProperty("user.home")); File currentDir = new File(System.getProperty("user.dir")); List<File> configLocations = new LinkedList<File>(); configLocations.addAll(Arrays.asList(new File[] { new File("/etc/veracity.config"), new File(homeDir, ".veracity.config"), new File(currentDir, "config.xml") })); String customConfigFileProperty = System.getProperty("veracity.configFile"); if (customConfigFileProperty != null) { configLocations.clear(); configLocations.add(new File(customConfigFileProperty)); } File configFile = null; Iterator<File> i = configLocations.iterator(); while ((configFile == null || !configFile.exists()) && i.hasNext()) { configFile = i.next(); } LaunchParameters parameters; if (!configFile.exists()) { if (log.isDebugEnabled()) { log.debug("Creating default config file at " + configFile.getAbsolutePath()); } parameters = new LaunchParameters(); parameters.save(configFile); } else { if (log.isDebugEnabled()) { log.debug("Loading parameters from config file at " + configFile.getAbsolutePath()); } parameters = LaunchParameters.load(configFile); } parameters.readSystemProperties(); new Veracity(parameters); }
From source file:io.compgen.cgpipe.CGPipe.java
public static void main(String[] args) { String fname = null;/*from w ww. ja va 2 s . c o 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.microsoft.tfs.sdk.samples.console.LogConfigurationSample.java
private static void logAllLevels(final Log log, final String message) { log.trace(message);/*from w w w . j a v a2 s .c o m*/ log.debug(message); log.info(message); log.warn(message); log.error(message); log.fatal(message); }
From source file:com.curl.orb.security.RemoteServiceAnnotationChecker.java
/** * Check the PublicService annotation. Throw AccessException if false. * /* ww w .j a v a2s. c o m*/ * @param cls the class * @throws AccessException */ public static void check(Class<?> cls, Environment environment) throws AccessException { // ignore security if (environment == null) return; RemoteService remoteServiceAnnotation = (RemoteService) cls.getAnnotation(RemoteService.class); if (!Modifier.isPublic(cls.getModifiers()) || remoteServiceAnnotation == null || !environment.contain(remoteServiceAnnotation.value())) { Log log = LogFactory.getLog(RemoteServiceAnnotationChecker.class); log.debug("Cannot allow to access the class [" + cls.getName() + "]"); throw new AccessException("Cannot allow to access the class [" + cls.getName() + "]"); } // TODO: Cache the class(cls). Which is faster, cache or annotation? }
From source file:com.nineteendrops.tracdrops.client.core.MessageUtils.java
public static String registerDebugLog(Log log, String key, String... parameters) { String errorMessage = getMessage(key, parameters); log.debug(errorMessage); return errorMessage; }
From source file:kr.co.aim.nanoframe.orm.SQLLogUtil.java
public static void logBeforeExecuting(String sql, Log log) { if (log.isDebugEnabled()) log.debug("SQL [" + sql + "]"); }