List of usage examples for java.util.logging Level ALL
Level ALL
To view the source code for java.util.logging Level ALL.
Click Source Link
From source file:com.vectorcast.plugins.vectorcastexecution.VectorCASTSetup.java
/** * Perform the build step. Copy the scripts from the archive/directory to the workspace * @param build build//from ww w.ja va 2 s.com * @param workspace workspace * @param launcher launcher * @param listener listener */ @Override public void perform(Run<?, ?> build, FilePath workspace, Launcher launcher, TaskListener listener) { FilePath destScriptDir = new FilePath(workspace, "vc_scripts"); JarFile jFile = null; try { String path = null; String override_path = System.getenv("VCAST_VC_SCRIPTS"); String extra_script_path = SCRIPT_DIR; Boolean directDir = false; if (override_path != null && !override_path.isEmpty()) { path = override_path; extra_script_path = ""; directDir = true; String msg = "VectorCAST - overriding vc_scripts. Copying from '" + path + "'"; Logger.getLogger(VectorCASTSetup.class.getName()).log(Level.ALL, msg); } else { path = VectorCASTSetup.class.getProtectionDomain().getCodeSource().getLocation().getPath(); path = URLDecoder.decode(path, "utf-8"); } File testPath = new File(path); if (testPath.isFile()) { // Have jar file... jFile = new JarFile(testPath); Enumeration<JarEntry> entries = jFile.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); if (entry.getName().startsWith("scripts")) { String fileOrDir = entry.getName().substring(8); // length of scripts/ FilePath dest = new FilePath(destScriptDir, fileOrDir); if (entry.getName().endsWith("/")) { // Directory, create destination dest.mkdirs(); } else { // File, copy it InputStream is = VectorCASTSetup.class.getResourceAsStream("/" + entry.getName()); dest.copyFrom(is); } } } } else { // Have directory File scriptDir = new File(path + extra_script_path); processDir(scriptDir, "./", destScriptDir, directDir); } } catch (IOException ex) { Logger.getLogger(VectorCASTSetup.class.getName()).log(Level.SEVERE, null, ex); } catch (InterruptedException ex) { Logger.getLogger(VectorCASTSetup.class.getName()).log(Level.SEVERE, null, ex); } finally { if (jFile != null) { try { jFile.close(); } catch (IOException ex) { // Ignore } } } }
From source file:org.ensembl.healthcheck.StandaloneTestRunner.java
public Logger getLogger() { if (logger == null) { logger = Logger.getLogger(StandaloneTestRunner.class.getCanonicalName()); ConsoleHandler localConsoleHandler = new ConsoleHandler(); localConsoleHandler.setFormatter(new Formatter() { DateFormat format = new SimpleDateFormat("dd-M-yyyy hh:mm:ss"); @Override//from w w w. j a va 2s .c o m public String format(LogRecord record) { return String.format("%s %s %s : %s%n", format.format(new Date(record.getMillis())), record.getSourceClassName(), record.getLevel().toString(), record.getMessage()); } }); if (options.isVerbose()) { localConsoleHandler.setLevel(Level.ALL); logger.setLevel(Level.ALL); } else { localConsoleHandler.setLevel(Level.INFO); logger.setLevel(Level.INFO); } logger.setUseParentHandlers(false); logger.addHandler(localConsoleHandler); } return logger; }
From source file:org.jenkinsci.plugins.workflow.WorkflowTest.java
@RandomlyFails("never printed 'finished waiting'") @Test//from w ww . j a va2 s . c om public void buildShellScriptAcrossDisconnect() throws Exception { story.addStep(new Statement() { @SuppressWarnings("SleepWhileInLoop") @Override public void evaluate() throws Throwable { Logger LOGGER = Logger.getLogger(DurableTaskStep.class.getName()); LOGGER.setLevel(Level.FINE); Handler handler = new ConsoleHandler(); handler.setLevel(Level.ALL); LOGGER.addHandler(handler); DumbSlave s = new DumbSlave("dumbo", "dummy", tmp.getRoot().getAbsolutePath(), "1", Node.Mode.NORMAL, "", new JNLPLauncher(), RetentionStrategy.NOOP, Collections.<NodeProperty<?>>emptyList()); story.j.jenkins.addNode(s); startJnlpProc(); p = story.j.jenkins.createProject(WorkflowJob.class, "demo"); File f1 = new File(story.j.jenkins.getRootDir(), "f1"); File f2 = new File(story.j.jenkins.getRootDir(), "f2"); new FileOutputStream(f1).close(); p.setDefinition(new CpsFlowDefinition("node('dumbo') {\n" + " sh 'touch \"" + f2 + "\"; while [ -f \"" + f1 + "\" ]; do sleep 1; done; echo finished waiting; rm \"" + f2 + "\"'\n" + " echo 'OK, done'\n" + "}")); startBuilding(); while (!f2.isFile()) { Thread.sleep(100); } assertTrue(b.isBuilding()); Computer c = s.toComputer(); assertNotNull(c); killJnlpProc(); while (c.isOnline()) { Thread.sleep(100); } startJnlpProc(); while (c.isOffline()) { Thread.sleep(100); } assertTrue(f2.isFile()); assertTrue(f1.delete()); while (f2.isFile()) { Thread.sleep(100); } story.j.assertBuildStatusSuccess(JenkinsRuleExt.waitForCompletion(b)); story.j.assertLogContains("finished waiting", b); story.j.assertLogContains("OK, done", b); killJnlpProc(); } }); }
From source file:fr.ens.biologie.genomique.eoulsan.Main.java
/** * Initialize the application logger./* w ww. ja v a 2 s. c om*/ */ private void initApplicationLogger() { // Disable parent Handler getLogger().setUseParentHandlers(false); // Set log level to all before setting the real log level with // BufferedHandler getLogger().setLevel(Level.ALL); // Add Buffered handler as unique Handler getLogger().addHandler(this.handler); // Set the formatter this.handler.setFormatter(Globals.LOG_FORMATTER); // Set the log level if (this.logLevel != null) { try { this.handler.setLevel(Level.parse(this.logLevel.toUpperCase())); } catch (IllegalArgumentException e) { Common.showErrorMessageAndExit("Unknown log level (" + this.logLevel + "). Accepted values are [SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST]."); } } else { this.handler.setLevel(Globals.LOG_LEVEL); } // Set the log file in arguments if (this.logFile != null) { try { this.handler.addHandler(getLogHandler(new File(this.logFile).getAbsoluteFile().toURI())); } catch (IOException e) { Common.errorExit(e, "Error while creating log file: " + e.getMessage()); } } }
From source file:hu.sztaki.lpds.pgportal.portlets.asm.SymbolMap.java
public String throwError(String message, int prio) { System.out.print(prio + "# [ERROR] " + message); Logger.getLogger(ASM_SamplePortlet.class.getName()).log(Level.ALL, message); if (prio <= verbose_level) return message; // errorMessage=message; if (prio <= verbose_level_log) writeLog(message, prio);/* ww w. jav a 2 s . c o m*/ return ""; }
From source file:alma.acs.logging.AcsLogger.java
/** * Logs the given <code>LogRecord</code>. * The record can be modified or dropped by the optional filters provided in {@link #addLogRecordFilter(alma.acs.logging.AcsLogger.LogRecordFilter)}. * <p>/*from www.j ava 2 s . c o m*/ * Adding of context information: * <ul> * <li> If the LogRecord has a parameter that is a map which contains additional information * about the line of code, thread, etc., the log record will be taken as provided, and no context * information will be added. This can be useful if * <ul> * <li> the log record was reconstructed from a remote error by the ACS error handling code * (see <code>AcsJException</code>), or * <li> if in very exceptional cases application code needs to manipulate such information by hand. * </ul> * <li> otherwise, context information is inferred, similar to {@link LogRecord#inferCaller()}, * but additionally including thread name and line of code. * </ul> * Note that by overloading this method, we intercept all logging activities of the base class. * * @see java.util.logging.Logger#log(java.util.logging.LogRecord) */ public void log(LogRecord record) { // Throw exception if level OFF was used to log this record, see http://jira.alma.cl/browse/COMP-1928 // Both Level.OFF and AcsLogLevel.OFF use the same value INTEGER.max, but we anyway check for both. if (record.getLevel().intValue() == Level.OFF.intValue() || record.getLevel().intValue() == AcsLogLevel.OFF.intValue()) { throw new IllegalArgumentException( "Level OFF must not be used for actual logging, but only for level filtering."); } StopWatch sw_all = null; if (PROFILE) { sw_all = new StopWatch(null); } // Level could be null and must then be inherited from the ancestor loggers, // e.g. during JDK shutdown when the log level is nulled by the JDK LogManager Logger loggerWithLevel = this; while (loggerWithLevel != null && loggerWithLevel.getLevel() == null && loggerWithLevel.getParent() != null) { loggerWithLevel = loggerWithLevel.getParent(); } int levelValue = -1; if (loggerWithLevel.getLevel() == null) { // HSO 2007-09-05: With ACS 6.0.4 the OMC uses this class (previously plain JDK logger) and has reported // that no level was found, which yielded a NPE. To be investigated further. // Probably #createUnconfiguredLogger was used without setting parent logger nor log level. // Just to be safe I add the necessary checks and warning message that improve over a NPE. if (!noLevelWarningPrinted) { System.out.println("Logger configuration error: no log level found for logger " + getLoggerName() + " or its ancestors. Will use Level.ALL instead."); noLevelWarningPrinted = true; } // @TODO: decide if resorting to ALL is desirable, or to use schema defaults, INFO, etc levelValue = Level.ALL.intValue(); } else { // level is fine, reset the flag to print the error message again when log level is missing. noLevelWarningPrinted = false; levelValue = loggerWithLevel.getLevel().intValue(); } // filter by log level to avoid unnecessary retrieval of context data. // The same check will be repeated by the base class implementation of this method that gets called afterwards. if (record.getLevel().intValue() < levelValue || levelValue == offValue) { return; } // modify the logger name if necessary if (loggerName != null) { record.setLoggerName(loggerName); } // check if this record already has the context data attached which ACS needs but the JDK logging API does not provide LogParameterUtil paramUtil = new LogParameterUtil(record); Map<String, Object> specialProperties = paramUtil.extractSpecialPropertiesMap(); if (specialProperties == null) { // we prepend the special properties map to the other parameters specialProperties = LogParameterUtil.createPropertiesMap(); List<Object> paramList = paramUtil.getNonSpecialPropertiesMapParameters(); paramList.add(0, specialProperties); record.setParameters(paramList.toArray()); String threadName = Thread.currentThread().getName(); specialProperties.put(LogParameterUtil.PARAM_THREAD_NAME, threadName); specialProperties.put(LogParameterUtil.PARAM_PROCESSNAME, this.processName); specialProperties.put(LogParameterUtil.PARAM_SOURCEOBJECT, this.sourceObject); // Get the stack trace StackTraceElement stack[] = (new Throwable()).getStackTrace(); // search for the first frame before the "Logger" class. int ix = 0; boolean foundNonLogFrame = false; while (ix < stack.length) { StackTraceElement frame = stack[ix]; String cname = frame.getClassName(); if (!foundNonLogFrame && !loggerClassNames.contains(cname)) { // We've found the relevant frame. record.setSourceClassName(cname); record.setSourceMethodName(frame.getMethodName()); int lineNumber = frame.getLineNumber(); specialProperties.put(LogParameterUtil.PARAM_LINE, Long.valueOf(lineNumber)); foundNonLogFrame = true; if (this.callStacksToBeIgnored.isEmpty()) { break; // performance optimization: avoid checking all "higher" stack frames } } if (foundNonLogFrame) { if (callStacksToBeIgnored.contains(concatenateIgnoreLogData(cname, frame.getMethodName()))) { //System.out.println("Won't log record with message " + record.getMessage()); return; } } ix++; } // We haven't found a suitable frame, so just punt. This is // OK as we are only committed to making a "best effort" here. } StopWatch sw_afterAcsLogger = null; if (PROFILE) { sw_afterAcsLogger = sw_all.createStopWatchForSubtask("afterAcsLogger"); LogParameterUtil logParamUtil = new LogParameterUtil(record); logParamUtil.setStopWatch(sw_afterAcsLogger); } // Let the delegate or Logger base class handle the rest. if (delegate != null) { delegate.log(record); } else { super.log(record); } if (PROFILE) { sw_afterAcsLogger.stop(); sw_all.stop(); long elapsedNanos = sw_all.getLapTimeNanos(); if (profileSlowestCallStopWatch == null || profileSlowestCallStopWatch.getLapTimeNanos() < elapsedNanos) { profileSlowestCallStopWatch = sw_all; } profileLogTimeStats.addValue(elapsedNanos); if (profileLogTimeStats.getN() >= profileStatSize) { String msg = "Local logging times in ms for the last " + profileStatSize + " logs: "; msg += "mean=" + profileMillisecFormatter.format(profileLogTimeStats.getMean() * 1E-6); msg += ", median=" + profileMillisecFormatter.format(profileLogTimeStats.getPercentile(50) * 1E-6); msg += ", stdev=" + profileMillisecFormatter.format(profileLogTimeStats.getStandardDeviation() * 1E-6); msg += "; details of slowest log (from "; msg += IsoDateFormat.formatDate(profileSlowestCallStopWatch.getStartTime()) + "): "; msg += profileSlowestCallStopWatch.getSubtaskDetails(); System.out.println(msg); profileSlowestCallStopWatch = null; profileLogTimeStats.clear(); } } }
From source file:MailHandlerDemo.java
/** * Example for priority messages by generation rate. If the push filter is * triggered the message is high priority. Otherwise, on close any remaining * messages are sent. If the capacity is set to the <code> * ##logging.properties/*from w w w . j a v a2 s.com*/ * MailHandlerDemo.handlers=com.sun.mail.util.logging.MailHandler * com.sun.mail.util.logging.MailHandler.subject=Push filter demo * com.sun.mail.util.logging.MailHandler.pushLevel=ALL * com.sun.mail.util.logging.MailHandler.pushFilter=com.sun.mail.util.logging.DurationFilter * com.sun.mail.util.logging.DurationFilter.records=2 * com.sun.mail.util.logging.DurationFilter.duration=1 * 60 * 1000 * ## * </code> */ private static void initWithPushFilter() { MailHandler h = new MailHandler(); h.setSubject("Push filter demo"); h.setPushLevel(Level.ALL); h.setPushFilter(new DurationFilter(2, 1L * 60L * 1000L)); LOGGER.addHandler(h); }
From source file:de.cismet.cids.custom.objecteditors.utils.VermessungUmleitungPanel.java
/** * DOCUMENT ME!/*ww w . jav a 2 s . co m*/ */ private void deleteFile() { final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() { @Override protected Boolean doInBackground() throws Exception { if (initError) { return false; } final String filename = createFilename(); final File f = File.createTempFile(filename, ".txt"); return webDavHelper.deleteFileFromWebDAV(filename + ".txt", createDirName(), getConnectionContext()); } @Override protected void done() { try { if (!get()) { final org.jdesktop.swingx.error.ErrorInfo ei = new ErrorInfo( org.openide.util.NbBundle.getMessage(VermessungUmleitungPanel.class, "VermessungUmleitungPanel.errorDialog.title"), org.openide.util.NbBundle.getMessage(VermessungUmleitungPanel.class, "VermessungUmleitungPanel.errorDialog.delete.message"), null, null, null, Level.ALL, null); JXErrorPane.showDialog( StaticSwingTools.getParentFrameIfNotNull(VermessungUmleitungPanel.this), ei); editor.handleEscapePressed(); if (escapeText != null) { tfName.setText(escapeText); } else { tfName.setText(""); } } else { editor.handleUmleitungDeleted(); } } catch (InterruptedException ex) { LOG.error("Deleting link file worker was interrupted", ex); } catch (ExecutionException ex) { LOG.error("Error in deleting link file worker", ex); final org.jdesktop.swingx.error.ErrorInfo ei = new ErrorInfo( org.openide.util.NbBundle.getMessage(VermessungUmleitungPanel.class, "VermessungUmleitungPanell.errorDialog.title"), org.openide.util.NbBundle.getMessage(VermessungUmleitungPanel.class, "VermessungUmleitungPanel.errorDialog.delete.message"), ex.getMessage(), null, ex, Level.ALL, null); JXErrorPane.showDialog(StaticSwingTools.getParentFrameIfNotNull(VermessungUmleitungPanel.this), ei); } } }; worker.execute(); }
From source file:ca.sfu.federation.viewer.propertysheet.PlanePropertySheet.java
private void jtfYActionListener(java.awt.event.ActionEvent evt) { String command = evt.getActionCommand(); logger.log(Level.ALL, "ComponentSheet jtfYActionListener fired {0}", command); try {// ww w .ja v a 2 s.c om BeanProxy proxy = new BeanProxy(this.target); proxy.set("Y", evt.getActionCommand()); } catch (Exception ex) { String stack = ExceptionUtils.getFullStackTrace(ex); logger.log(Level.WARNING, "{0}", stack); } }
From source file:ca.sfu.federation.viewer.propertysheet.PlanePropertySheet.java
private void jtfZActionListener(java.awt.event.ActionEvent evt) { String command = evt.getActionCommand(); logger.log(Level.ALL, "ComponentSheet jtfZActionListener fired {0}", command); try {// www. jav a2s. c o m BeanProxy proxy = new BeanProxy(this.target); proxy.set("Z", evt.getActionCommand()); } catch (Exception ex) { String stack = ExceptionUtils.getFullStackTrace(ex); logger.log(Level.WARNING, "{0}", stack); } }