当前位置: 首页>>代码示例>>Java>>正文


Java Logger类代码示例

本文整理汇总了Java中java.util.logging.Logger的典型用法代码示例。如果您正苦于以下问题:Java Logger类的具体用法?Java Logger怎么用?Java Logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Logger类属于java.util.logging包,在下文中一共展示了Logger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: LogService

import java.util.logging.Logger; //导入依赖的package包/类
private LogService(Logger logger) {
	super(logger);

	// setup a log file if the execution mode can access the filesystem (e.g. not for RA)
	// we want our logfile to look the same regardless of any user settings, so ignore
	// a possible user logging property config file
	if (RapidMiner.getExecutionMode().canAccessFilesystem()) {
		try {
			FileHandler logFileHandler = new FileHandler(FileSystemService.getLogFile().getAbsolutePath(), false);
			logFileHandler.setLevel(Level.ALL);
			logFileHandler.setFormatter(new SimpleFormatter());
			LogService.getRoot().addHandler(logFileHandler);
		} catch (IOException e) {
			LogService.getRoot().log(Level.WARNING, "com.rapidminer.logservice.logfile.failed_to_init", e.getMessage());
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:18,代码来源:LogService.java

示例2: msgReceived

import java.util.logging.Logger; //导入依赖的package包/类
@OnMessage
public void msgReceived(ChatMessage msg, Session s) {
    if (msg.getMsg().equals(LOGOUT_MSG)) {
        try {
            s.close();
            return;
        } catch (IOException ex) {
            Logger.getLogger(ChatServer.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    Predicate<Session> filterCriteria = null;
    if (!msg.isPrivate()) {
        //for ALL (except self)
        filterCriteria = (session) -> !session.getUserProperties().get("user").equals(user);
    } else {
        String privateRecepient = msg.getRecepient();
        //private IM
        filterCriteria = (session) -> privateRecepient.equals(session.getUserProperties().get("user"));
    }

    s.getOpenSessions().stream()
            .filter(filterCriteria)
            //.forEach((session) -> session.getAsyncRemote().sendText(msgContent));
            .forEach((session) -> session.getAsyncRemote().sendObject(new Reply(msg.getMsg(), user, msg.isPrivate())));

}
 
开发者ID:abhirockzz,项目名称:websocket-chat,代码行数:27,代码来源:ChatServer.java

示例3: isDelayed

import java.util.logging.Logger; //导入依赖的package包/类
/**
 * Delays given task if neccessary - e.g. projects are currently openning - and reschedules the task if indexing is running
 * This method waits for projects to open and thus blocks the current thread.
 * @param task task to be delayed
 * @param logger 
 * @param logMessagePrefix
 * @return true if the task was rescheduled
 */
public boolean isDelayed (RequestProcessor.Task task, Logger logger, String logMessagePrefix) {
    boolean rescheduled = false;
    DelayedScan scan = getRegisteredScan(task);
    Future<Project[]> projectOpenTask = OpenProjects.getDefault().openProjects();
    if (!projectOpenTask.isDone()) {
        try {
            projectOpenTask.get();
        } catch (Exception ex) {
            // not interested
        }
    }
    if (IndexingBridge.getInstance().isIndexingInProgress()
            && (BLOCK_INDEFINITELY || scan.waitingLoops * WAITING_PERIOD < MAX_WAITING_TIME)) {
        // do not steal disk from openning projects and indexing tasks
        Level level = ++scan.waitingLoops < 10 ? Level.FINE : Level.INFO;
        logger.log(level, "{0}: Scanning in progress, trying again in {1}ms", new Object[]{logMessagePrefix, WAITING_PERIOD}); //NOI18N
        task.schedule(WAITING_PERIOD); // try again later
        rescheduled = true;
    } else {
        scan.waitingLoops = 0;
    }
    return rescheduled;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:DelayScanRegistry.java

示例4: getStringList

import java.util.logging.Logger; //导入依赖的package包/类
/**
 * Helper method to get an array of Strings from preferences.
 *
 * @param prefs storage
 * @param key key of the String array
 * @return List<String> stored List of String or an empty List if the key was not found (order is preserved)
 */
public static List<String> getStringList(Preferences prefs, String key) {
    List<String> retval = new ArrayList<String>();
    try {
        String[] keys = prefs.keys();
        for (int i = 0; i < keys.length; i++) {
            String k = keys[i];
            if (k != null && k.startsWith(key)) {
                int idx = Integer.parseInt(k.substring(k.lastIndexOf('.') + 1));
                retval.add(idx + "." + prefs.get(k, null));
            }
        }
        List<String> rv = new ArrayList<String>(retval.size());
        rv.addAll(retval);
        for (String s : retval) {
            int pos = s.indexOf('.');
            int index = Integer.parseInt(s.substring(0, pos));
            rv.set(index, s.substring(pos + 1));
        }
        return rv;
    } catch (Exception ex) {
        Logger.getLogger(Utils.class.getName()).log(Level.INFO, null, ex);
        return new ArrayList<String>(0);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:Utils.java

示例5: setUp

import java.util.logging.Logger; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    TopLogging.initializeQuietly();
    
    super.setUp();

    this.clearWorkDir();
    final File _wd = this.getWorkDir();
    workDir = FileUtil.toFileObject(_wd);

    FileObject cache = workDir.createFolder("cache");
    CacheFolder.setCacheFolder(cache);
    RootsListener.setUseAsyncListneres(false);

    ruSync = new RepositoryUpdaterTest.TestHandler();
    final Logger logger = Logger.getLogger(RepositoryUpdater.class.getName() + ".tests");
    logger.setLevel(Level.FINEST);
    logger.addHandler(ruSync);

    RepositoryUpdaterTest.waitForRepositoryUpdaterInit();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:RepositoryUpdater2Test.java

示例6: main

import java.util.logging.Logger; //导入依赖的package包/类
/**
 * Main method.
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
    Logger log = Logger.getLogger(Main.class.getName());

    log.log(Level.WARNING,"Starting server .....");

    Logger log2 = Logger.getLogger("org.glassfish");
    log2.setLevel(Level.ALL);
    log2.addHandler(new java.util.logging.ConsoleHandler());

    final HttpServer server = startServer();
    System.out.println(String.format("Jersey app started with WADL available at "
            + "%sapplication.wadl\nHit enter to stop it...", BASE_URI));
    System.in.read();
    server.stop();
}
 
开发者ID:Fiware,项目名称:NGSI-LD_Wrapper,代码行数:21,代码来源:Main.java

示例7: TinyTxLogger

import java.util.logging.Logger; //导入依赖的package包/类
public TinyTxLogger(Class<?> targetClass) {
	if (targetClass == null)
		throw new AssertionError("TinyTxLogger error: targetClass can not be null.");
	try {
		Class<?> logFactoryClass = Class.forName("org.apache.commons.logging.LogFactory");
		Method method = logFactoryClass.getMethod("getLog", Class.class);
		commonLogger = method.invoke(logFactoryClass, targetClass);
		commonLoggerInfoMethod = commonLogger.getClass().getMethod("info", Object.class);
		commonLoggerWarnMethod = commonLogger.getClass().getMethod("warn", Object.class);
		commonLoggerErrorMethod = commonLogger.getClass().getMethod("error", Object.class);
	} catch (Exception e) {
		// do nothing
	}

	if (commonLogger == null || commonLoggerWarnMethod == null) {
		if (firstRun)
			System.err.println("TinyTxLogger failed to load org.apache.commons.logging.LogFactory. Use JDK logger.");// NOSONAR
		jdkLogger = Logger.getLogger(targetClass.getName());// use JDK log
	} else if (firstRun)
		System.out.println("org.apache.commons.logging.LogFactory loaded, DbProLogger use it as logger.");// NOSONAR
}
 
开发者ID:drinkjava2,项目名称:jTransactions,代码行数:22,代码来源:TinyTxLogger.java

示例8: conectar

import java.util.logging.Logger; //导入依赖的package包/类
public static Connection conectar(){
Connection con = null;
      Statement st = null;
      ResultSet rs = null;
      try {Class.forName("org.postgresql.Driver");}
      catch (ClassNotFoundException e) {e.printStackTrace();}
      String url = "";
      String user = "postgres";
      String password = "postgres";

      try {con = DriverManager.getConnection("jdbc:postgresql://pg01.stp.gov.py/tablero2015v3?useUnicode=true&characterEncoding=UTF-8&user=postgres&password=postgres");}
      catch (SQLException ex) {
          Logger lgr = Logger.getLogger(SqlHelper.class.getName());
          lgr.log(Level.SEVERE, ex.getMessage(), ex);
      } 
      return con;
 }
 
开发者ID:stppy,项目名称:tcp,代码行数:18,代码来源:ConnectionConfiguration.java

示例9: fillTrie

import java.util.logging.Logger; //导入依赖的package包/类
@Override
protected void fillTrie(Logger logger, Trie<Attribution> trie, Corpus corpus) throws IOException, ModuleException {
	try {
		CandidateClassifier classifier = tomapClassifier.readClassifier(this, logger);
		Collection<Candidate> candidates = readCandidates(logger);
		for (Candidate cand : candidates) {
			List<Attribution> attributions = classifier.classify(cand);
			if (attributions.isEmpty()) {
				continue;
			}
			CharSequence key = getCandidateKey(cand);
			for (Attribution attr : attributions) {
				trie.addEntry(key, attr);
			}
		}
	}
	catch (SAXException|ParserConfigurationException e) {
		rethrow(e);
	}
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:21,代码来源:TomapProjector.java

示例10: checkUserName

import java.util.logging.Logger; //导入依赖的package包/类
private boolean checkUserName(ReportPanel panel) {
    checkingResult = true;
    try {
        String login = URLEncoder.encode(panel.getUserName(), "UTF-8");
        String encryptedPasswd = URLEncoder.encode(PasswdEncryption.encrypt(new String(panel.getPasswdChars())), "UTF-8");
        char[] array = new char[100];
        URL checkingServerURL = new URL(NbBundle.getMessage(Installer.class, "CHECKING_SERVER_URL", login, encryptedPasswd));
        URLConnection connection = checkingServerURL.openConnection();
        connection.setRequestProperty("User-Agent", "NetBeans");
        connection.setReadTimeout(20000);
        Reader reader = new InputStreamReader(connection.getInputStream());
        int length = reader.read(array);
        checkingResult = Boolean.valueOf(new String(array, 0, length));
    } catch (UnsupportedEncodingException ex) {
        Exceptions.printStackTrace(ex);
    } catch (Exception exception) {
        Logger.getLogger(Installer.class.getName()).log(Level.INFO, "Checking password failed", exception); // NOI18N
    }
    return checkingResult;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:Installer.java

示例11: put

import java.util.logging.Logger; //导入依赖的package包/类
/**
 * Stores a List of Strings into Preferences node under the given key.
 *
 * @param prefs storage
 * @param key key of the String array
 * @param value List of Strings to write (order will be preserved)
 */
public static void put(Preferences prefs, String key, List<String> value) {
    try {
        String[] keys = prefs.keys();
        for (int i = 0; i < keys.length; i++) {
            String k = keys[i];
            if (k != null && k.startsWith(key + ".")) {
                prefs.remove(k);
            }
        }
        int idx = 0;
        for (String s : value) {
            prefs.put(key + "." + idx++, s);
        }
    } catch (BackingStoreException ex) {
        Logger.getLogger(Utils.class.getName()).log(Level.INFO, null, ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:Utils.java

示例12: listProperties

import java.util.logging.Logger; //导入依赖的package包/类
public List<String> listProperties(String wmiClass) throws WMIException {
	List<String> foundPropertiesList = new ArrayList<>();
	try {
		String rawData = getWMIStub().listProperties(wmiClass, this.namespace, this.computerName);

		String[] dataStringLines = rawData.split(NEWLINE_REGEX);

		for (final String line : dataStringLines) {
			if (!line.isEmpty()) {
				foundPropertiesList.add(line.trim());
			}
		}

		List<String> notAllowed = Arrays.asList("Equals", "GetHashCode", "GetType", "ToString");
		foundPropertiesList.removeAll(notAllowed);

		return foundPropertiesList;
	} catch (Exception ex) {
		Logger.getLogger(WMI4Java.class.getName()).log(Level.SEVERE, GENERIC_ERROR_MSG, ex);
		throw new WMIException(ex);
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:23,代码来源:WMI4Java.java

示例13: run

import java.util.logging.Logger; //导入依赖的package包/类
@Override public void run() 
{
    playback();  
    
    while (update())
    {
        try {Thread.sleep(sleepTime);} 
        catch (InterruptedException ex) {Logger.getLogger(OggStreamer.class.getName()).log(Level.SEVERE, null, ex);}
    
    }
    
    Debug.log("playback has ended");
    canStart = true;
    m_OggDecoder.reset();
    
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:17,代码来源:OggStreamer.java

示例14: parse

import java.util.logging.Logger; //导入依赖的package包/类
public static MobsModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
    FilterParser filterParser = context.needModule(FilterParser.class);
    Element mobsEl = doc.getRootElement().getChild("mobs");
    Filter mobsFilter = StaticFilter.DENY;
    if(mobsEl != null) {
        if(context.getProto().isNoOlderThan(ProtoVersions.FILTER_FEATURES)) {
            mobsFilter = filterParser.parseProperty(mobsEl, "filter");
        } else {
            Element filterEl = XMLUtils.getUniqueChild(mobsEl, "filter");
            if(filterEl != null) {
                mobsFilter = filterParser.parseElement(filterEl);
            }
        }
    }
    return new MobsModule(mobsFilter);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:17,代码来源:MobsModule.java

示例15: save

import java.util.logging.Logger; //导入依赖的package包/类
public boolean save(Drug drug) {
    if (dbll.isValid(drug)) {
        if (dbll.isUnique(drug, 0)) {
            con = connection.geConnection();
            try {
                pst = con.prepareStatement("insert into drug values(?,?,?,?,?)");
                pst.setString(1, null);
                pst.setString(2, drug.getName());
                pst.setString(3, drug.getGenricName());
                pst.setString(4, drug.getNote());
                pst.setString(5, drug.getCreatedAt());
                pst.executeUpdate();
                pst.close();
                con.close();
                connection.con.close();
                return true;
            } catch (SQLException ex) {
                Logger.getLogger(DrugGetway.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

    }
    return false;
}
 
开发者ID:kmrifat,项目名称:Dr-Assistant,代码行数:25,代码来源:DrugGetway.java


注:本文中的java.util.logging.Logger类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。