`

framework log4j / logback / slf4j

阅读更多

s

Log4j 1.x版 引发线程blocked死锁问题 / 使用apache log解决高并发下log4j引起大量线程block问题

http://www.aiprograming.com/b/pengpeng/23

http://zl378837964.iteye.com/blog/2373591

http://m.blog.csdn.net/article/details?id=52401328

Apache Log4j是一个基于Java的日志记录工具,用起来非常方便,但是Log4j 1.x如果使用不慎,会引起死锁问题,进行导致整个网站的宕机

 

 

WebLog Expert V5.6 Beta 3

http://wt.duote.com/soft/6057.html

http://70.duote.com.cn/wlexpert.exe

WebLog Expert 能够分析网站的流量记录,将原始的流量记录分析出Activity statistics、Access statistics、Information about visitors、Referrers、Information about errors等基本而重要的流量信息,帮助你了解网友对于你的网站的使用状况。

 

webloger digger ?

 

 

http://guoqinhua1986-126-com.iteye.com/blog/231244

 

********************LOG4J配置文件 log4j.properties*********** 
# Configure logging for testing: optionally with log file 
log4j.rootLogger=WARN, stdout 
# log4j.rootLogger=WARN, stdout, logfile 
log4j.appender.stdout=org.apache.log4j.ConsoleAppender 
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n 
log4j.appender.logfile=org.apache.log4j.FileAppender 
log4j.appender.logfile.File=target/spring.log 
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout 
log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n

 

package com.idemfactor.crm.dao;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.idemfactor.crm.model.Role;

/**
 * Data access object (DAO) for domain model class Role.
 * 
 * @see com.idemfactor.crm.model.Role
 * @author MyEclipse Persistence Tools
 */

public class RoleDAO extends HibernateDaoSupport {
    private static final Log log = LogFactory.getLog(RoleDAO.class);
    // property constants
    public static final String ROLE_NAME = "roleName";

    protected void initDao() {
	// do nothing
    }

    public void save(Role transientInstance) {
	log.debug("saving Role instance");
	getHibernateTemplate().save(transientInstance);
	log.debug("save successful");
    }

    public void delete(Role persistentInstance) {
	log.debug("deleting Role instance");
	getHibernateTemplate().delete(persistentInstance);
	log.debug("delete successful");
    }

    public Role findById(java.lang.Integer id) {
	log.debug("getting Role instance with id: " + id);
	Role instance = (Role) getHibernateTemplate().get(
		"com.idemfactor.crm.model.Role", id);
	return instance;
    }

    public List<Role> findByExample(Role instance) {
	log.debug("finding Role instance by example");
	List<Role> results = getHibernateTemplate().findByExample(instance);
	log.debug("find by example successful, result size: " + results.size());
	return results;
    }

    public List<Role> findByProperty(String propertyName, Object value) {
	log.debug("finding Role instance with property: " + propertyName
		+ ", value: " + value);
	String queryString = "from Role as model where model." + propertyName
		+ "= ?";
	return getHibernateTemplate().find(queryString, value);
    }

    public List<Role> findAll() {
	log.debug("finding all Role instances");
	String queryString = "from Role";
	return getHibernateTemplate().find(queryString);
    }

    public Role merge(Role detachedInstance) {
	log.debug("merging Role instance");
	Role result = (Role) getHibernateTemplate().merge(detachedInstance);
	log.debug("merge successful");
	return result;
    }

    public void attachDirty(Role instance) {
	log.debug("attaching dirty Role instance");
	getHibernateTemplate().saveOrUpdate(instance);
	log.debug("attach successful");
    }

    public void attachClean(Role instance) {
	log.debug("attaching clean Role instance");
	getHibernateTemplate().lock(instance, LockMode.NONE);
	log.debug("attach successful");
    }
}

 

  log4j.properties

 

log4j.rootLogger=info, stdout
log4j.logger.com.idemfactor=debug

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d{ISO8601}] %5p [%t] (%c{1}:%L) - %m%n

#log4j.appender.R=org.apache.log4j.RollingFileAppender
#log4j.appender.R.layout=org.apache.log4j.PatternLayout
#log4j.appender.R.layout.ConversionPattern=[%d{ISO8601}] %5p [%t] (%c{1}:%L) - %m%n
#log4j.appender.R.File=/tmp/fs.log
#log4j.appender.R.MaxFileSize=1000KB
#log4j.appender.R.MaxBackupIndex=7


# Need this to show all exception details in struts
log4j.logger.org.apache.struts.action.ExceptionHandler=debug

 

end

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics