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

📄 log.java

📁 java数据库操作工具类
💻 JAVA
字号:
package com.baosight.util;

import java.io.*;
import java.util.logging.Logger.*;
import java.util.*;
import java.text.SimpleDateFormat;

public class Log {
  FileOutputStream out; // declare a file output object
  PrintStream p; // declare a print stream object
public static void main(String args[]){
  createLogger(Log.class,"main()","this is a test!");
}
  public static void createLogger(Class fileclass, String method, String text) {
    try {
      Log log = new Log();
      log.fileout(fileclass, method, text);
    }
    catch (Exception e) {
      System.err.println("Error writing to file" + e);
    }
    System.out.println("  LogOutput:   " + fileclass + "->" + method + "=>" +
                       text);
  }

 private void fileout(Class fileclass, String method, String text) throws Exception {
    SimpleDateFormat btdateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    SimpleDateFormat btdateformat2 = new SimpleDateFormat("yyyy-MM-dd");
    synchronized (this) {
      Date date = new Date();
      out = new FileOutputStream("FRG_LOGGER" + btdateformat2.format(date) +
                                 ".txt", true);
      p = new PrintStream(out);
      p.println("[" + btdateformat.format(date) + "]:[" + fileclass + "->" +
                method + "=>]" + text);
      p.close();
    }
  }
}

⌨️ 快捷键说明

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