List of usage examples for java.util.logging Logger fine
public void fine(Supplier<String> msgSupplier)
From source file:Logging.java
public static void main(String[] args) { Logger log = Logger.getLogger("global"); log.finest("A"); log.finer("B"); log.fine("C"); log.config("D"); log.info("E"); log.warning("O"); log.severe("A"); }
From source file:MainClass.java
public static void main(String[] args) { Logger logger = Logger.getLogger("com.java2s.log"); logger.severe("severe"); logger.warning("warning"); logger.info("info"); logger.config("config"); logger.fine("fine"); logger.finer("finer"); logger.finest("value =" + 42); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Logger logger = Logger.getLogger("com.mycompany"); FileHandler fh = new FileHandler("mylog.txt"); fh.setFormatter(new SimpleFormatter()); logger.addHandler(fh);//from w w w .ja v a 2 s . c o m // fh = new FileHandler("mylog.xml"); // fh.setFormatter(new XMLFormatter()); // logger.addHandler(fh); // Log a few messages logger.severe("my severe message"); logger.warning("my warning message"); logger.info("my info message"); logger.config("my config message"); logger.fine("my fine message"); logger.finer("my finer message"); logger.finest("my finest message"); }
From source file:inflor.core.utils.PlotUtils.java
public static AbstractFCChart createPlot(ChartSpec plotSpec) { PlotTypes type = plotSpec.getPlotType(); AbstractFCChart newPlot = null;//ww w .ja v a 2 s. c om if (type.equals(PlotTypes.SCATTER)) { newPlot = new ScatterPlot(plotSpec); } else if (type.equals(PlotTypes.HISTOGRAM)) { newPlot = new HistogramPlot(plotSpec); } else if (type.equals(PlotTypes.DENSITY)) { newPlot = new DensityPlot(plotSpec); } else { Logger logger = LogFactory.createLogger(PlotUtils.class.getName()); logger.fine("PlotType not supported: " + type.name()); } return newPlot; }
From source file:com.modeln.build.common.tool.CMnCmdLineTool.java
/** * Write the elapsed time to a logger./* w ww . j a va2 s . com*/ * * @param start Starting date * @param end Ending date * @param msg Message to display */ public static void logElapsedTime(Logger logger, Date start, Date end, String msg) { String elapsedTime = getElapsedTime(start, end); logger.fine(msg + elapsedTime); }
From source file:com.idega.hibernate.HibernateUtil.java
public static SessionFactory configure() { try {//w w w . j av a 2s . c om Logger loggerRoot = Logger.getLogger(HibernateUtil.class.getName()); Logger loggerConnect = Logger.getLogger("Connect"); loggerRoot.fine("In HibernateUtil try-clause"); loggerRoot.warning("In HibernateUtil try-clause"); loggerConnect.fine("In HibernateUtil try-clause via loggerConnect DEBUG*****"); // Create the SessionFactory from hibernate.cfg.xml Properties properties = getProperties(); Configuration configuration = new Configuration(); configuration.setProperties(properties); return configuration.buildSessionFactory(); } catch (Throwable ex) { // Make sure you log the exception, as it might be swallowed System.err.println("Initial SessionFactory creation failed." + ex); throw new ExceptionInInitializerError(ex); } }
From source file:net.roboconf.agent.internal.misc.UserDataUtils.java
/** * Configures the agent from VMWare.//w w w. j av a 2s. c om * @param logger a logger * @return the agent's data, or null if they could not be parsed */ public static AgentProperties findParametersForVmware(Logger logger) { File propertiesFile = new File("/tmp/roboconf.properties"); try { int retries = 30; while ((!propertiesFile.exists() || !propertiesFile.canRead()) && retries-- > 0) { logger.fine("Agent tries to read properties file " + propertiesFile + ": trial #" + (30 - retries)); try { Thread.sleep(2000); } catch (InterruptedException e) { throw new IOException("Can't read properties file: " + e); } } AgentProperties result = AgentProperties.readIaasProperties(Utils.readPropertiesFile(propertiesFile)); /* * HACK for specific IaaS configurations (using properties file in a VMWare-like manner) * Try to pick IP address... in the case we are on OpenStack or any IaaS with amazon-compatible API * Some configurations (with floating IPs) do not provide network interfaces exposing public IPs ! */ InputStream in = null; try { URL userDataUrl = new URL("http://169.254.169.254/latest/meta-data/public-ipv4"); in = userDataUrl.openStream(); ByteArrayOutputStream os = new ByteArrayOutputStream(); Utils.copyStreamSafely(in, os); String ip = os.toString("UTF-8"); if (!AgentUtils.isValidIP(ip)) { // Failed retrieving public IP: try private one instead Utils.closeQuietly(in); userDataUrl = new URL("http://169.254.169.254/latest/meta-data/local-ipv4"); in = userDataUrl.openStream(); os = new ByteArrayOutputStream(); Utils.copyStreamSafely(in, os); ip = os.toString("UTF-8"); } if (AgentUtils.isValidIP(ip)) result.setIpAddress(os.toString("UTF-8")); } catch (IOException e) { Utils.logException(logger, e); } finally { Utils.closeQuietly(in); } /* HACK ends here (see comment above). Removing it is harmless on classical VMWare configurations. */ return result; } catch (IOException e) { logger.fine("Agent failed to read properties file " + propertiesFile); return null; } }
From source file:net.roboconf.target.docker.internal.DockerUtils.java
/** * Creates a Docker client from target properties. * @param targetProperties a non-null map * @return a Docker client//from w w w . j a v a2 s . c o m * @throws TargetException if something went wrong */ public static DockerClient createDockerClient(Map<String, String> targetProperties) throws TargetException { // Validate what needs to be validated. Logger logger = Logger.getLogger(DockerHandler.class.getName()); logger.fine("Setting the target properties."); verifyDockerClient(targetProperties); String edpt = targetProperties.get(DockerHandler.ENDPOINT); if (Utils.isEmptyOrWhitespaces(edpt)) edpt = "tcp://localhost:4243"; // The configuration is straight-forward. Builder config = DefaultDockerClientConfig.createDefaultConfigBuilder().withDockerHost(edpt) .withRegistryUsername(targetProperties.get(DockerHandler.USER)) .withRegistryPassword(targetProperties.get(DockerHandler.PASSWORD)) .withRegistryEmail(targetProperties.get(DockerHandler.EMAIL)) .withApiVersion(targetProperties.get(DockerHandler.VERSION)); // Build the client. DockerClientBuilder clientBuilder = DockerClientBuilder.getInstance(config.build()); return clientBuilder.build(); }
From source file:net.roboconf.target.docker.internal.DockerUtils.java
/** * Finds an image by ID or by tag./*from w w w . j a v a 2s . co m*/ * @param name an image ID or a tag name (can be null) * @param dockerClient a Docker client (not null) * @return an image, or null if none matched */ public static Image findImageByIdOrByTag(String name, DockerClient dockerClient) { Image image = null; if (!Utils.isEmptyOrWhitespaces(name)) { Logger logger = Logger.getLogger(DockerUtils.class.getName()); List<Image> images = dockerClient.listImagesCmd().exec(); if ((image = DockerUtils.findImageById(name, images)) != null) logger.fine("Found a Docker image with ID " + name); else if ((image = DockerUtils.findImageByTag(name, images)) != null) logger.fine("Found a Docker image with tag " + name); } return image; }
From source file:com.qualogy.qafe.core.errorhandling.ErrorProcessor.java
public static ErrorResult processError(ListIterator<? extends Item> itrItem, Item triggeredItem, ApplicationContext context, Window window, DataIdentifier dataId, ExternalException externalException, Logger log) { if (externalException == null) { throw new IllegalArgumentException("ExternalException is null, and therefore cannot be processed"); }/*from w w w .j a va 2s . c o m*/ if (externalException.getCause() == null) { throw new IllegalArgumentException( "ExternalException cause is null, and therefore cannot be processed"); } ErrorResult errorResult = new ErrorResult(); ErrorHandler errorHandler = null; try { if (itrItem != null) { List<ErrorHandler> errorHandlerList = getErrorHandlers(itrItem, context, window); errorHandler = resolveErrorHandler(errorHandlerList, externalException); if (errorHandler != null) { log.fine("ErrorHandler found for exception [" + externalException.getCause().getClass() + "], continue in alternative path"); logError(errorHandler, context, dataId, log); errorResult.setItems(errorHandler.getResultItems()); // Go to the position of the errorHandler, // so further processing can be continued goBackToItemPosition(itrItem, errorHandler, context, window); } } } finally { // Rethrow if handler is not defined (no action specified) // or handler specifies that the exception should be rethrown errorResult = resolveRethrow(errorResult, errorHandler, externalException); if (externalException.getCause() != null) { String errorMessage = externalException.getErrorMessage(); if (errorMessage == null) { errorMessage = externalException.getMessage(); } DataStore.store(dataId, DataStore.KEY_ERROR_MESSAGE, errorMessage); } } return errorResult; }