List of usage examples for java.util.logging Level CONFIG
Level CONFIG
To view the source code for java.util.logging Level CONFIG.
Click Source Link
From source file:org.jboss.capedwarf.common.env.AbstractEnvironment.java
public void log(String category, Level level, String msg, Throwable t) { if (level == null) { verbose(category, msg, t);//from w w w.j ava 2 s . c om return; } String name = level.getName(); if (Level.SEVERE.equals(level)) name = "ERROR"; else if (Level.CONFIG.equals(level)) name = "DEBUG"; List<Class<?>> types = new ArrayList<Class<?>>(); types.add(String.class); types.add(String.class); if (t != null) types.add(Throwable.class); try { Method m = getMethod(name, types.toArray(new Class<?>[types.size()])); List<Object> args = new ArrayList<Object>(); args.add(category); args.add(msg); if (t != null) args.add(t); m.invoke(null, args.toArray(new Object[args.size()])); } catch (Exception ignored) { verbose(category, msg, t); } }
From source file:com.adr.taskexecutor.ui.TaskExecutorRemote.java
/** Creates new form TaskExecutorRemote */ public TaskExecutorRemote() { initComponents();//from ww w . jav a 2 s.co m jLoggingLevel.addItem(Level.SEVERE); jLoggingLevel.addItem(Level.WARNING); jLoggingLevel.addItem(Level.INFO); jLoggingLevel.addItem(Level.CONFIG); jLoggingLevel.addItem(Level.FINE); jLoggingLevel.addItem(Level.FINER); jLoggingLevel.addItem(Level.FINEST); jLoggingLevel.addItem(Level.OFF); jLoggingLevel.addItem(Level.ALL); jURL.setText(Configuration.getInstance().getPreference("remote.serverurl", "http://localhost/taskexecutoree/executetask")); jLoggingLevel.setSelectedItem(Level .parse(Configuration.getInstance().getPreference("remote.logginglevel", Level.INFO.toString()))); jTrace.setSelected(Boolean .parseBoolean(Configuration.getInstance().getPreference("remote.trace", Boolean.FALSE.toString()))); jStats.setSelected(Boolean .parseBoolean(Configuration.getInstance().getPreference("remote.stats", Boolean.TRUE.toString()))); }
From source file:net.community.chest.gitcloud.facade.AbstractEnvironmentInitializer.java
@Override public void contextInitialized(ServletContextEvent sce) { Log curLogger = logger;/*w ww .ja v a 2s. co m*/ try { ServletContext context = sce.getServletContext(); logger = ServletUtils.wrapServletContext(context, Level.CONFIG); contextInitialized(context); logger.info("contextInitialized(" + context.getContextPath() + ")"); } catch (Throwable t) { logger.error("Failed (" + t.getClass().getSimpleName() + ") to initialize: " + t.getMessage(), t); throw ExtendedExceptionUtils.toRuntimeException(t, true); } finally { logger = curLogger; } }
From source file:org.apache.tomee.jul.formatter.SimpleTomEEFormatterTest.java
@Test public void formatNotNullThrown() throws Exception { final String previousLineSeparatorProperty = System.getProperty(LINE_SEPARATOR_KEY); try {//from w ww . ja v a 2 s.c om final String lineSeparatorValue = "\n"; final String logMessage = "An example log record"; final Level level = Level.CONFIG; final String exceptionMessage = "An example exception"; final Throwable thrown = new Exception(exceptionMessage); System.setProperty(LINE_SEPARATOR_KEY, lineSeparatorValue); final LogRecord logRecordInput = new LogRecord(level, logMessage); logRecordInput.setThrown(thrown); final Formatter formatter = new SimpleTomEEFormatter(); final String actualFormatOutput = formatter.format(logRecordInput); final String expectedFormatOutput = level.getLocalizedName() + " - " + logMessage + lineSeparatorValue + ExceptionUtils.getStackTrace(thrown); assertEquals(expectedFormatOutput, actualFormatOutput); } finally { System.setProperty(LINE_SEPARATOR_KEY, previousLineSeparatorProperty); } }
From source file:cz.cuni.mff.d3s.tools.perfdoc.server.measuring.MeasureRequestHandler.java
@Override public void handle(HttpExchange exchange) throws IOException { log.log(Level.INFO, "Got new Ajax request. Starting to handle it."); //adding the right header Headers responseHeaders = exchange.getResponseHeaders(); responseHeaders.set("Access-Control-Allow-Origin", "*"); //getting the JSON request InputStream in = exchange.getRequestBody(); //gets the body of the output OutputStream responseBody = exchange.getResponseBody(); String userID = ""; MethodMeasurer measurer = null;/*from w w w . j av a 2 s . c om*/ MeasureRequest measureRequest = null; try (BufferedReader rd = new BufferedReader(new InputStreamReader(in, Charset.forName("UTF-8")))) { String requestBody = readAll(rd); log.log(Level.CONFIG, "The incoming message is: {0}", requestBody); //parsing incoming request measureRequest = new MeasureRequest(requestBody); measurer = new MethodMeasurer(measureRequest, lockBase); JSONObject obj = measurer.measure(); try { exchange.sendResponseHeaders(200, obj.toString().getBytes().length); responseBody.write(obj.toString().getBytes()); } catch (IOException ex) { log.log(Level.INFO, "Unable to send the results to the client", ex); } } catch (ClassNotFoundException ec) { sendErrorMessage("Unable to find a testedMethod/generator class", exchange, responseBody); } catch (IllegalArgumentException ex) { sendErrorMessage("The bad parameters were sent to server (There might be an error in generator).", exchange, responseBody); } catch (NoSuchMethodException ex) { sendErrorMessage(ex.getMessage(), exchange, responseBody); } catch (IOException ex) { sendErrorMessage("There was some problem while reading some file on the server.", exchange, responseBody); } catch (SQLException ex) { log.log(Level.SEVERE, "There was some problem when connecting to database", ex); } catch (Exception e) { System.out.println(e); e.printStackTrace(); } finally { try { in.close(); responseBody.close(); } catch (IOException ex) { //there is nothing we can do with it log.log(Level.INFO, "An exception occured when trying to close comunnication with client", ex); } } //results with highest priority are cached if (measurer != null && measureRequest != null && measureRequest.getMeasurementQuality().getPriority() == 4) { measurer.saveResultsAndCloseDatabaseConnection(); } log.log(Level.INFO, "Data were succesfully sent to the user ({0}).", userID); }
From source file:com.elasticbox.jenkins.k8s.repositories.api.PodRepositoryApiImpl.java
@Override public void delete(String kubeName, String namespace, String podName) throws RepositoryException { if (LOGGER.isLoggable(Level.CONFIG)) { LOGGER.config("Deleting Pod: " + podName); }/* www . j av a2 s .c o m*/ kubeRepository.getClient(kubeName).pods().inNamespace(namespace).withName(podName).delete(); }
From source file:org.mili.core.logging.java.JavaAdapter.java
org.mili.core.logging.Level transformLevel(Level level) { Validate.notNull(level, "level cannot be null!"); if (level == Level.ALL || level == Level.FINEST) { return org.mili.core.logging.Level.TRACE; } else if (level == Level.FINE || level == Level.FINER) { return org.mili.core.logging.Level.DEBUG; } else if (level == Level.INFO || level == Level.CONFIG) { return org.mili.core.logging.Level.INFO; } else if (level == Level.WARNING) { return org.mili.core.logging.Level.WARN; } else if (level == Level.SEVERE) { return org.mili.core.logging.Level.ERROR; } else {/*from w ww. j ava 2s. c o m*/ return org.mili.core.logging.Level.FATAL; } }
From source file:org.apache.tomee.util.SimpleTomEEFormatterTest.java
@Test public void formatNotNullThrown() throws Exception { final String previousLineSeparatorProperty = System.getProperty(LINE_SEPARATOR_KEY); try {/* ww w . j a va2s .c o m*/ final String lineSeparatorValue = "\n"; final String logMessage = "An example log record"; final Level level = Level.CONFIG; final String exceptionMessage = "An example exception"; final Throwable thrown = new Exception(exceptionMessage); System.setProperty(LINE_SEPARATOR_KEY, lineSeparatorValue); final LogRecord logRecordInput = new LogRecord(level, logMessage); logRecordInput.setThrown(thrown); final Formatter formatter = new SimpleTomEEFormatter(); final String actualFormatOutput = formatter.format(logRecordInput); final StringBuilder expectedFormatOutputSb = new StringBuilder(level.getLocalizedName()); expectedFormatOutputSb.append(" - ").append(logMessage).append(lineSeparatorValue); expectedFormatOutputSb.append(ExceptionUtils.getStackTrace(thrown)); final String expectedFormatOutput = expectedFormatOutputSb.toString(); assertEquals(expectedFormatOutput, actualFormatOutput); } finally { System.setProperty(LINE_SEPARATOR_KEY, previousLineSeparatorProperty); } }
From source file:nl.minvenj.pef.stream.LiveCapture.java
/** * Initializes a logger.//ww w.j av a2s . c o m * * @param logPath The location and name of the log file * @throws SecurityException on opening the log file * @throws IOException on opening the log file */ private static void initLogger(final String logPath) throws SecurityException, IOException, IllegalArgumentException { logFileHandler = new FileHandler(logPath, true); Logger initLogger = Logger.getLogger(""); logFileHandler.setFormatter(new SimpleFormatter()); initLogger.addHandler(logFileHandler); initLogger.setLevel(Level.CONFIG); }
From source file:org.diorite.impl.log.ForwardLogHandler.java
@Override public void publish(final LogRecord record) { final Logger logger = this.getLogger(record.getLoggerName()); final Throwable exception = record.getThrown(); final Level level = record.getLevel(); final String message = this.getFormatter().formatMessage(record); if (Objects.equals(level, Level.SEVERE)) { logger.error(message, exception); } else if (Objects.equals(level, Level.WARNING)) { logger.warn(message, exception); } else if (Objects.equals(level, Level.INFO)) { logger.info(message, exception); } else if (Objects.equals(level, Level.CONFIG)) { logger.debug(message, exception); } else {/*from w w w. j a v a 2s. c o m*/ logger.trace(message, exception); } }