日志文件的管理

王朝html/css/js·作者佚名  2006-12-17
宽屏版  字体: |||超大  

日志文件的管理

日志文件的管理 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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();

}

}

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有