List of usage examples for java.util.logging Logger getAnonymousLogger
public static Logger getAnonymousLogger()
From source file:org.objectpocket.storage.FileStore.java
protected void removeUnusedFiles() { if (indexBackup == null || index == null) { return;//from w ww. ja v a2 s . c o m } Set<String> filesToRemove = new HashSet<String>(); Map<String, Set<String>> oldMapping = indexBackup.getTypeToFilenamesMapping(); Map<String, Set<String>> newMapping = index.getTypeToFilenamesMapping(); // add all old filenames for (String typeName : oldMapping.keySet()) { filesToRemove.addAll(oldMapping.get(typeName)); } // remove all that are still in use for (String typeName : newMapping.keySet()) { filesToRemove.removeAll(newMapping.get(typeName)); } // remove files for (String filename : filesToRemove) { File f = new File(directory + "/" + filename); if (!f.delete()) { Logger.getAnonymousLogger().severe("Could not remove file from store. " + f.getPath()); } } }
From source file:ru.codeinside.gses.webui.executor.ArchiveFactory.java
static Component createForm(final Bid bid, ActivityImpl activity, ProcessEngine engine, ActivitiApp app, final Date toDate) { CommandExecutor commandExecutor = ((ServiceImpl) engine.getRuntimeService()).getCommandExecutor(); Map<String, String> historyValues = commandExecutor.execute(new Command<Map<String, String>>() { @Override//from w w w.j a v a 2 s. c om public Map<String, String> execute(CommandContext commandContext) { return getHistoryValues(bid, toDate); } }); FormValue formValue; String processDefinitionId = bid.getProcedureProcessDefinition().getProcessDefinitionId(); FormID formID = FormID.byProcessDefinitionId(processDefinitionId); if (isPropertyType(activity, "startEvent")) { formValue = commandExecutor.execute(new GetStartArchiveFormCmd(processDefinitionId, historyValues)); } else if (isPropertyType(activity, "userTask") && activity.getActivityBehavior() instanceof UserTaskActivityBehavior) { CustomTaskFormHandler taskFormHandler = (CustomTaskFormHandler) ((UserTaskActivityBehavior) activity .getActivityBehavior()).getTaskDefinition().getTaskFormHandler(); formValue = commandExecutor .execute(new GetTaskArchiveFormCmd(processDefinitionId, taskFormHandler, historyValues)); } else { formValue = null; } if (formValue == null) { return null; } if (StringUtils.isNotEmpty(formValue.getFormDefinition().getFormKey())) { return new EFormBuilder(formValue, formID).getForm(null, null); } ImmutableMap<String, PropertyNode> propertyNodes = formValue.getFormDefinition().getIndex(); if (propertyNodes.containsKey(API.JSON_FORM)) { String templateRef = null; String value = null; for (PropertyValue<?> propertyValue : formValue.getPropertyValues()) { if (propertyValue.getId().equals(API.JSON_FORM)) { templateRef = (String) propertyValue.getValue(); } else { if (propertyValue.getValue() instanceof byte[]) { try { value = new String((byte[]) propertyValue.getValue(), "UTF-8"); } catch (UnsupportedEncodingException e) { Logger.getAnonymousLogger().info("can't decode model!"); } } else { value = String.valueOf(propertyValue.getValue()); } } } if (value != null) { return JsonForm.createIntegration(formID, app, templateRef, value, true); } } FieldTree fieldTree = new FieldTree(formID); fieldTree.create(formValue); GridForm form = new GridForm(formID, fieldTree); form.setImmediate(true); return form; }
From source file:org.silverpeas.core.util.DBUtilIntegrationTest.java
private int nextUniqueIdUpdateForAnExistingTableShouldWorkAndConcurrency(final String tableName, final int nbThreads) throws SQLException, InterruptedException { Logger.getAnonymousLogger().info("Start at " + System.currentTimeMillis() + " with " + nbThreads + " threads for table " + tableName); final Thread[] threads = new Thread[nbThreads]; for (int i = 0; i < nbThreads; i++) { threads[i] = new Thread(() -> { try { int nextId = DBUtil.getNextId(tableName, "id"); Logger.getAnonymousLogger().info( "Next id for " + tableName + " is " + nextId + " at " + System.currentTimeMillis()); } catch (Exception e) { throw new RuntimeException(e); }//from w w w . java2s.co m }); } try { for (Thread thread : threads) { thread.start(); Thread.sleep(5); } for (Thread thread : threads) { thread.join(); } return actualMaxIdInUniqueIdFor(tableName); } finally { for (Thread thread : threads) { if (thread.isAlive()) { thread.interrupt(); } } } }
From source file:com.aperigeek.dropvault.web.dao.MongoFileService.java
protected InputStream readFile(File file, String username, char[] password) throws IOException { try {/*w ww .ja v a 2s .co m*/ ByteArrayOutputStream out = new ByteArrayOutputStream(); InputStream fIn = new BufferedInputStream(new FileInputStream(file)); Cipher cipher = Cipher.getInstance("Blowfish"); cipher.init(Cipher.DECRYPT_MODE, getSecretKey(username, password)); CipherInputStream in = new CipherInputStream(fIn, cipher); return in; } catch (Exception ex) { // TODO: better exception handling Logger.getAnonymousLogger().log(Level.SEVERE, "ERROR", ex); throw new RuntimeException(ex); } }
From source file:com.aperigeek.dropvault.web.dao.MongoFileService.java
protected File createDataFile(InputStream data, String username, char[] password) throws IOException { try {//from ww w . j av a2 s . c o m String fileName = UUID.randomUUID().toString(); File folder = new File(storageFolder, username); folder = new File(folder, fileName.substring(0, 2)); folder.mkdirs(); File file = new File(folder, fileName); Cipher cipher = Cipher.getInstance("Blowfish"); cipher.init(Cipher.ENCRYPT_MODE, getSecretKey(username, password)); OutputStream fOut = new BufferedOutputStream(new FileOutputStream(file)); CipherOutputStream out = new CipherOutputStream(fOut, cipher); InputStream in = new BufferedInputStream(data); byte[] buffer = new byte[2048]; int readed; while ((readed = in.read(buffer)) != -1) { out.write(buffer, 0, readed); } in.close(); out.flush(); out.close(); fOut.flush(); fOut.close(); return file; } catch (Exception ex) { // TODO: better exception handling Logger.getAnonymousLogger().log(Level.SEVERE, "ERROR", ex); throw new RuntimeException(ex); } finally { data.close(); } }
From source file:com.aperigeek.dropvault.web.dao.MongoFileService.java
protected KeyStore getKeyStore(String username, char[] password) { try {/*from w w w. j a v a2s .c o m*/ File keyStoreFile = new File(secretsFolder, username + ".jks"); KeyStore keyStore = KeyStore.getInstance("JCEKS"); if (keyStoreFile.exists()) { keyStore.load(new FileInputStream(keyStoreFile), password); return keyStore; } else { KeyGenerator gen = KeyGenerator.getInstance("Blowfish"); SecretKey key = gen.generateKey(); keyStore.load(null, password); keyStore.setEntry(username, new SecretKeyEntry(key), new KeyStore.PasswordProtection(password)); keyStore.store(new FileOutputStream(keyStoreFile), password); return keyStore; } } catch (Exception ex) { // TODO: better exception handling Logger.getAnonymousLogger().log(Level.SEVERE, "ERROR", ex); throw new RuntimeException(ex); } }
From source file:com.spinn3r.api.Main.java
public static void main(String[] args) throws Exception { // NOTE this could be cleaned up to pass the values into the config // object directly. // parse out propeties. String api = null;/*from w ww. ja va 2 s . com*/ for (int i = 0; i < args.length; ++i) { String v = args[i]; if (v.startsWith("--api")) { api = getOpt(v); } } if (api == null) api = "permalink"; // First. Determine which API you'd like to use. long after = -1; Format format = Format.PROTOSTREAM; String vendor = null; String remoteFilter = null; Long sleep_duration = null; boolean skip_description = false; String host = "api.spinn3r.com"; for (int i = 0; i < args.length; ++i) { String v = args[i]; if (v.startsWith("--vendor")) { vendor = getOpt(v); continue; } if (v.startsWith("--filter")) { filter = getOpt(v); continue; } if (v.startsWith("--remote-filter")) { remoteFilter = getOpt(v); continue; } if (v.startsWith("--show_results")) { show_results = Integer.parseInt(getOpt(v)); continue; } /* * The code for the --afterTimestamp must come * before the code for --after because --afterTimestamp * also matches startsWith("after"); */ if (v.startsWith("--afterTimestamp")) { after = Long.parseLong(getOpt(v)); continue; } if (v.startsWith("--after")) { after = getOptAsTimeInMillis(v); continue; } /* * The code for the --beforeTimestamp must come * before the code for --before because --beforeTimestamp * also matches startsWith("before"); */ if (v.startsWith("--beforeTimestamp")) { before = Long.parseLong(getOpt(v)); continue; } if (v.startsWith("--before")) { before = getOptAsTimeInMillis(v); continue; } if (v.startsWith("--range")) { range = Long.parseLong(getOpt(v)); continue; } if (v.startsWith("--recover")) { restore = true; continue; } if (v.startsWith("--sleep_duration")) { sleep_duration = Long.parseLong(getOpt(v)); continue; } if (v.startsWith("--save=")) { save = getOpt(v); continue; } if (v.startsWith("--save_method=")) { save_method = getOpt(v); continue; } if (v.startsWith("--skip_description=")) { skip_description = Boolean.parseBoolean(getOpt(v)); continue; } if (v.startsWith("--save_compressed=")) { saveCompressed = Boolean.parseBoolean(getOpt(v)); continue; } if (v.startsWith("--timing")) { timing = "true".equals(getOpt(v)); continue; } if (v.startsWith("--debug")) { logLevel = Level.FINE; debugLogFilePath = getOpt(v); continue; } /* * if ( v.startsWith( "--spam_probability" ) ) { * config.setSpamProbability( Double.parseDouble( getOpt( v ) ) ); * continue; } */ if (v.startsWith("--dump_fields=")) { dumpFields = Boolean.parseBoolean(getOpt(v)); continue; } if (v.startsWith("--dump=")) { dump = Boolean.parseBoolean(getOpt(v)); continue; } if (v.startsWith("--csv=")) { csv = Boolean.parseBoolean(getOpt(v)); continue; } if (v.startsWith("--memory")) { System.out.printf("max memory: %s\n", Runtime.getRuntime().maxMemory()); System.exit(0); } if (v.startsWith("--host")) { host = getOpt(v); continue; } if (v.startsWith("--enable3")) { // is now default continue; } if (v.startsWith("com.spinn3r")) continue; if (v.startsWith("--api")) continue; // That's an unknown command line option. Exit. System.err.printf("Unknown command line option: %s\n", v); syntax(); System.exit(1); } /* * Set the log level */ Logger anonymousLogger = Logger.getAnonymousLogger(); anonymousLogger.setLevel(logLevel); if (debugLogFilePath != null) { anonymousLogger.addHandler(new FileHandler(debugLogFilePath)); } Factory factory = new Factory(); String restoreURL = null; if (save != null && restore) { File savedir = new File(save); Collection<File> logFiles = getLogFiles(savedir); PermalinkLogReaderAdapter adapter = getRestoreURLS(logFiles); restoreURL = adapter.getLastUrl(); long ctr = adapter.getLastCtr(); for (File file : logFiles) { if (!file.delete()) throw new IOException("Failed to delete " + file.toString()); } factory.enableLogging(savedir, 1000000); if (restoreURL != null) { factory.enableRestart(ctr, restoreURL); } logManager = factory.getInjector().getInstance(TransactionHistoryManager.class); } else { logManager = factory.getInjector().getInstance(TransactionHistoryManager.class); } Config<? extends BaseResult> config = null; BaseClient<? extends BaseResult> client = null; if (api.startsWith("feed")) { config = new FeedConfig(); client = new FeedClient(); } else if (api.startsWith("comment")) { config = new CommentConfig(); client = new CommentClient(); } else { config = new PermalinkConfig(); client = new PermalinkClient( restoreURL != null ? ImmutableList.of(restoreURL) : Collections.<String>emptyList()); } config.setCommandLine(StringUtils.join(args, " ")); config.setApi(api); config.setFormat(format); config.setVendor(vendor); config.setHost(host); config.setFilter(remoteFilter); config.setSkipDescription(skip_description); if (sleep_duration != null) client.setSleepDuration(sleep_duration); // assert that we have all required options. if (config.getVendor() == null) { syntax(); System.exit(1); } long maxMemory = Runtime.getRuntime().maxMemory(); long requiredMemory = (save == null) ? PARSE_REQUIRED_MEMORY : SAVE_REQUIRED_MEMORY; if (maxMemory < requiredMemory) { System.out.printf("ERROR: Reference client requires at least 2GB of memory.\n"); System.out.printf("\n"); System.out.printf("Now running with: %s vs %s required\n", maxMemory, requiredMemory); System.out.printf("\n"); System.out.printf("Add -Xmx%dM to your command line and run again.\n", requiredMemory / (1024 * 1024)); System.exit(1); } // use defaults System.out.println("Using vendor: " + config.getVendor()); System.out.println("Using api: " + api); if (after > -1) System.out.printf("After: %s (%s)\n", ISO8601DateParser.toString(Config.timestampToDate(after)), after); if (before > -1) System.out.printf("Before: %s (%s)\n", ISO8601DateParser.toString(Config.timestampToDate(before)), before); System.out.println("Saving results to disk: " + save); // Fetch for the last 5 minutes and then try to get up to date. In // production you'd want to call setFirstRequestURL from the // getLastRequestURL returned from fetch() below if (after == -1) { after = Config.millisecondsToTimestamp(System.currentTimeMillis()); after = after - INTERVAL; } config.setAfterTimestamp(after); new Main().exec(client, config); }
From source file:com.devnexus.ting.web.controller.admin.RegistrationController.java
@RequestMapping(value = "/s/admin/{eventKey}/uploadRegistration", method = RequestMethod.POST) public ModelAndView uploadGroupRegistration(ModelAndView model, HttpServletRequest request, @PathVariable(value = "eventKey") String eventKey, @Valid @ModelAttribute("registerForm") UploadGroupRegistrationForm uploadForm, BindingResult bindingResult) throws FileNotFoundException, IOException, InvalidFormatException { EventSignup signUp = eventSignupRepository.getByEventKey(eventKey); model.getModelMap().addAttribute("event", signUp.getEvent()); if (bindingResult.hasErrors()) { model.getModelMap().addAttribute("registerForm", uploadForm); model.setViewName("/admin/upload-registration"); } else {//from w w w . j a v a 2s. co m boolean hasErrors = false; try { Workbook wb = WorkbookFactory.create(uploadForm.getRegistrationFile().getInputStream()); Sheet sheet = wb.getSheetAt(0); Cell contactNameCell = sheet.getRow(0).getCell(1, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); Cell contactEmailCell = sheet.getRow(1).getCell(1, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); Cell contactPhoneCell = sheet.getRow(2).getCell(1, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); Cell registrationReferenceCell = sheet.getRow(3).getCell(1, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); if (contactNameCell.getStringCellValue().isEmpty()) { hasErrors = true; bindingResult.addError(new ObjectError("registrationFile", "Contact Name Empty")); } if (contactEmailCell.getStringCellValue().isEmpty()) { hasErrors = true; bindingResult.addError(new ObjectError("registrationFile", "Contact Email Empty")); } if (contactPhoneCell.getStringCellValue().isEmpty()) { hasErrors = true; bindingResult.addError(new ObjectError("registrationFile", "Contact Phone Empty")); } if (registrationReferenceCell.getStringCellValue().isEmpty()) { hasErrors = true; bindingResult.addError(new ObjectError("registrationFile", "Registration Reference Empty")); } if (!hasErrors) { RegistrationDetails details = new RegistrationDetails(); details.setContactEmailAddress(contactEmailCell.getStringCellValue()); details.setContactName(contactNameCell.getStringCellValue()); details.setContactPhoneNumber(contactPhoneCell.getStringCellValue()); details.setRegistrationFormKey(registrationReferenceCell.getStringCellValue()); details.setEvent(signUp.getEvent()); details.setFinalCost(BigDecimal.ZERO); details.setInvoice("Invoiced"); details.setPaymentState(RegistrationDetails.PaymentState.PAID); int attendeeRowIndex = 7; Row attendeeRow = sheet.getRow(attendeeRowIndex); while (attendeeRow != null) { attendeeRow = sheet.getRow(attendeeRowIndex); if (attendeeRow != null) { Cell firstName = attendeeRow.getCell(0, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); Cell lastName = attendeeRow.getCell(1, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); Cell emailAddress = attendeeRow.getCell(2, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); Cell city = attendeeRow.getCell(3, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); Cell state = attendeeRow.getCell(4, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); Cell country = attendeeRow.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); Cell ticketType = attendeeRow.getCell(6, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); Cell company = attendeeRow.getCell(7, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); Cell jobTitle = attendeeRow.getCell(8, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); Cell tshirtSize = attendeeRow.getCell(9, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); Cell vegetarian = attendeeRow.getCell(10, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); Cell sponsorMessages = attendeeRow.getCell(11, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); if (firstName.getStringCellValue().isEmpty()) { break; } if (lastName.getStringCellValue().isEmpty()) { bindingResult.addError(new ObjectError("registrationFile", " row " + (attendeeRowIndex + 1) + " missing information : lastName")); hasErrors = true; break; } if (emailAddress.getStringCellValue().isEmpty()) { bindingResult.addError(new ObjectError("registrationFile", " row " + (attendeeRowIndex + 1) + " missing information : emailAddress")); hasErrors = true; break; } if (city.getStringCellValue().isEmpty()) { bindingResult.addError(new ObjectError("registrationFile", " row " + (attendeeRowIndex + 1) + " missing information : city")); hasErrors = true; break; } if (state.getStringCellValue().isEmpty()) { bindingResult.addError(new ObjectError("registrationFile", " row " + (attendeeRowIndex + 1) + " missing information : state ")); hasErrors = true; break; } if (country.getStringCellValue().isEmpty()) { bindingResult.addError(new ObjectError("registrationFile", " row " + (attendeeRowIndex + 1) + " missing information : country")); hasErrors = true; break; } if (company.getStringCellValue().isEmpty()) { bindingResult.addError(new ObjectError("registrationFile", " row " + (attendeeRowIndex + 1) + " missing information : company")); hasErrors = true; break; } if (jobTitle.getStringCellValue().isEmpty()) { bindingResult.addError(new ObjectError("registrationFile", " row " + (attendeeRowIndex + 1) + " missing information : jobTitle")); hasErrors = true; break; } if (ticketType.getStringCellValue().isEmpty()) { bindingResult.addError(new ObjectError("registrationFile", " row " + (attendeeRowIndex + 1) + " missing information: ticket type")); hasErrors = true; break; } if (tshirtSize.getStringCellValue().isEmpty()) { bindingResult.addError(new ObjectError("registrationFile", " row " + (attendeeRowIndex + 1) + " missing information: t shirt ")); hasErrors = true; break; } if (vegetarian.getStringCellValue().isEmpty() || !(vegetarian.getStringCellValue().equalsIgnoreCase("no") || vegetarian.getStringCellValue().equalsIgnoreCase("yes"))) { bindingResult.addError( new ObjectError("registrationFile", " row " + (attendeeRowIndex + 1) + " missing information. Vegetarian option should be yes or no ")); hasErrors = true; break; } if (sponsorMessages.getStringCellValue().isEmpty() || !(sponsorMessages.getStringCellValue().equalsIgnoreCase("no") || sponsorMessages.getStringCellValue().equalsIgnoreCase("yes"))) { bindingResult.addError( new ObjectError("registrationFile", " row " + (attendeeRowIndex + 1) + " missing information. Sponsor message should be yes or no ")); hasErrors = true; break; } TicketOrderDetail detail = new TicketOrderDetail(); detail.setCity(city.getStringCellValue()); detail.setCompany(company.getStringCellValue()); detail.setCouponCode(""); detail.setCountry(country.getStringCellValue()); detail.setEmailAddress(emailAddress.getStringCellValue()); detail.setFirstName(firstName.getStringCellValue()); detail.setJobTitle(jobTitle.getStringCellValue()); detail.setLastName(lastName.getStringCellValue()); detail.setSponsorMayContact( sponsorMessages.getStringCellValue().equalsIgnoreCase("no") ? "false" : "true"); detail.setState(state.getStringCellValue()); detail.setTicketGroup( Long.parseLong(ticketType.getStringCellValue().split("-\\|-")[1].trim())); detail.setLabel(businessService.getTicketGroup(detail.getTicketGroup()).getLabel()); detail.settShirtSize(tshirtSize.getStringCellValue()); detail.setVegetarian( vegetarian.getStringCellValue().equalsIgnoreCase("no") ? "false" : "true"); detail.setRegistration(details); details.getOrderDetails().add(detail); attendeeRowIndex++; } } if (uploadForm.getOverrideRegistration()) { try { RegistrationDetails tempRegistration = businessService .getRegistrationForm(registrationReferenceCell.getStringCellValue()); tempRegistration.getOrderDetails().forEach((oldDetail) -> { oldDetail.setRegistration(null); }); tempRegistration.getOrderDetails().clear(); tempRegistration.getOrderDetails().addAll(details.getOrderDetails()); tempRegistration.getOrderDetails().forEach((detail) -> { detail.setRegistration(tempRegistration); }); details = tempRegistration; businessService.updateRegistration(details, uploadForm.getSendEmail()); } catch (EmptyResultDataAccessException ignore) { businessService.updateRegistration(details, uploadForm.getSendEmail()); } } else { try { RegistrationDetails tempRegistration = businessService .getRegistrationForm(registrationReferenceCell.getStringCellValue()); hasErrors = true; bindingResult.addError(new ObjectError("registrationFile", "Registration with this key exists, please check \"Replace Registrations\".")); } catch (EmptyResultDataAccessException ignore) { businessService.updateRegistration(details, uploadForm.getSendEmail()); } } } } catch (Exception ex) { hasErrors = true; Logger.getAnonymousLogger().log(Level.SEVERE, ex.getMessage(), ex); bindingResult.addError(new ObjectError("registrationFile", ex.getMessage())); } if (hasErrors) { model.setViewName("/admin/upload-registration"); } else { model.setViewName("/admin/index"); } } return model; }
From source file:net.sf.dvstar.transmission.TransmissionView.java
private void initLogger() { try {//from www. ja v a 2 s . co m FileHandler logFile = new FileHandler("%h/.JTransmission.log", true); logFile.setFormatter(new SimpleFormatter()); globalLogger = Logger.getAnonymousLogger(); Handler h[] = getGlobalLogger().getHandlers(); for (int i = 0; i < h.length; i++) { globalLogger.removeHandler(h[i]); } globalLogger.addHandler(logFile); globalLogger.setLevel(logginLevel); globalLogger.setUseParentHandlers(false); globalLogger.log(Level.INFO, "Started"); logFile.flush(); } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:nl.strohalm.cyclos.utils.logging.LoggingHandler.java
/** * Creates a new logger/*from w w w . j a v a 2s .co m*/ */ private Logger init(final Level level, final String file) { final LogSettings logSettings = settingsService.getLogSettings(); final Logger logger = Logger.getAnonymousLogger(); logger.setLevel(level); logger.setUseParentHandlers(false); try { final FileUnits units = logSettings.getMaxLengthPerFileUnits(); final FileHandler fileHandler = new FileHandler(file, units.calculate(logSettings.getMaxLengthPerFile()), logSettings.getMaxFilesPerLog(), true); fileHandler.setFormatter(logFormatter); fileHandler.setEncoding(settingsService.getLocalSettings().getCharset()); logger.addHandler(fileHandler); } catch (final Exception e) { final ConsoleHandler consoleHandler = new ConsoleHandler(); consoleHandler.setFormatter(logFormatter); try { consoleHandler.setEncoding(settingsService.getLocalSettings().getCharset()); } catch (final Exception e1) { // Just ignore } logger.addHandler(consoleHandler); logger.log(Level.WARNING, "Unable to create logger for file " + file); } return logger; }