⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 diagnosticlogging.java

📁 关于Ultraseek的一些用法,刚初学,所以都是比较简单
💻 JAVA
字号:
/* -*- mode:java; indent-tabs-mode:nil; c-basic-offset:2 -*- *  $RCSFile$ $Revision: 1.11 $ $Date: 2006/02/01 00:20:31 $ *  Copyright (c) 2004 Autonomy Corp.  All Rights Reserved. */import java.io.*;import java.util.*;import java.util.logging.*;import com.ultraseek.xpa.search.*;import com.ultraseek.xpa.server.*;/** * Activates XPA Diagnostic logging. * <p> * This sample requires JDK 1.4 or higher. * <p> * This application demonstrates how to configure the * JDK 1.4 java.util.logging package to receive diagnostic logging * messages that XPA generates. If you don't configure logging in some * way, log messages are sent to System.err. * <p> * There are other logging packages you can configure for XPA, * such as Log4j.  * Consult the documentation accompanying those packages and the  * <a target="_blank" href="http://jakarta.apache.org/commons/logging/"> * Jakarta Commons Logging package</a>. * <p> * To use this application, edit the file "Sample.properties"  * to point to your Ultraseek server. * * @since XPA2.2 * @requires JDK 1.4 */public class DiagnosticLogging {  /**   * Loads parameters from the file Sample.properties   */  static String getString(String key, String def) {    try {      String resourceName = System.getProperty("Sample");      if (resourceName==null) resourceName = "Sample";      ResourceBundle settings = ResourceBundle.getBundle( resourceName );      return settings.getString(key);    } catch (MissingResourceException e) {      return def;    } catch (Exception e) {      System.out.println( "Property file problem: "  + e );      return def;    }  }  static final String serverName  = getString("UltraseekServer.host",                                               "software-demo.ultraseek.com");  static final int    serverPort  = Integer.valueOf(getString("UltraseekServer.port",                                                               "80")).intValue();  static final String serverProto = getString("UltraseekServer.protocol",                                               "http");  static UltraseekServer server = new UltraseekServer(serverName, serverPort, serverProto);  /**   * Show the results of the query, and log it.   */  static void demoLogging(String query)    throws IOException {    Query q = Query.parse(query);    try {      SearchResultList srl = server.search(q);      // Show summary of search results.      System.out.println();      System.out.println( "" + srl.getDocCount() + " documents were searched.");      System.out.println( "" + srl.getResultCount() + " document(s) match your query.");      System.out.println( "" + srl.size() + " SearchResults are available for display.");    } catch (QueryNotSupportedException e) {      System.out.println( "Query problem: " + e );    }  }  static public String LOGFILE = "DiagnosticLogging.log";  static public void main(String args[])     throws IOException {    /* Initialize logging */    // logger for all of XPA    Logger logger = Logger.getLogger("com.ultraseek.xpa");    // log to file "DiagnosticLogging.log"    FileHandler handler = new FileHandler(LOGFILE);    // use simple text format instead of the verbose XML file format    handler.setFormatter(new SimpleFormatter());    // register handler (FINE and higher messages still also logged to stderr)    logger.addHandler(handler);    // log ALL messages    logger.setLevel(Level.ALL);    System.out.println("Diagnostic Logging Demo");    System.out.println("Using Ultraseek at " + server );    System.out.println(" (version " + server.getVersionString() +")" );    System.out.println("\nThe XPA Diagnostic log will be written to: " + LOGFILE);    InputStreamReader inputStreamReader = new InputStreamReader(System.in);    BufferedReader bufferedReader = new BufferedReader(inputStreamReader);    while (true) {      System.out.print("\n\nEnter a query (EOF to end): ");      String line = bufferedReader.readLine();      if (line==null) break;      try {        demoLogging( line );      } catch (IOException e) {        System.out.println( "Problem communicating with server: " + e );      } catch (XPARuntimeException e) {        System.out.println( "Problem communicating with server: " + e.getCause() );      }    }    System.out.println("The XPA Diagnostic Log is in file: " + LOGFILE);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -