网站制作

本类阅读TOP10

·IIS 安装配置全攻略
·用VS.NET打开网上下载的.NET web项目出错的解决办法
·HTML 4.0 语言快速参考
·限制TextArea区的文字输入数量
·如何在网页上实现进度条
·Apache的配置步骤及测试
·谈谈Jesse James Garrett提到的Ajax
·html基础学习笔记(2)
·页面垂直居中的两种方法
·用asp遍历目录下文件的例子

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
日志文件的管理

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
import org.apache.log4j.*;

/**
 * @author 
 *
 * To change this generated comment edit the template variable "typecomment":
 * Window>Preferences>Java>Templates.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */
public class JBWriteLog {
 
  Logger log = Logger.getLogger("writelog.JBWriteLog");
  Logger logE = Logger.getLogger("writelog.JBWriteLog");
  //文件路径斜扛
  char xg = java.io.File.separatorChar;
  /**
   * 构造函数:并设置配置文件
   * @param PropertyFile:配置文件路径
   */
  public JBWriteLog(String PropertyFile) throws Exception{
    PropertyConfigurator.configure(PropertyFile);
  }
  /**
   * 写日志操作
   * @param logInfo:日志一个条目的内容
   * @throws Exception
   */
  public void writeLog(String logInfo) throws Exception{
    try {
      //引入普通信息日志配置文件
      //PropertyConfigurator.configure("."+xg+"properties"+xg+propertiesFileName);

      log.info(logInfo);
    }
    catch (Exception e) {

      e.printStackTrace();
      throw e;
    }
 
}

}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/**
 * @author 
 *
 * To change this generated comment edit the template variable "typecomment":
 * Window>Preferences>Java>Templates.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */
public class TestLog {
 
 /**
  * Constructor
  */
    public TestLog() {
    }


    public static void main(String[] args) {
       try{
          JBWriteLog wl = new JBWriteLog("/properties/log4j.properties");
          wl.writeLog("1");
          wl.writeLog("2");
          wl.writeLog("3");
          wl.writeLog("4");
          }catch(Exception e)
           {
           e.printStackTrace();
           }

      }

}




相关文章

相关软件