log4j对象改变日志级别
编程技术  /  houtizong 发布于 3年前   463
log4j.rootLogger=ERROR,FILE,CONSOLE,EXECPTION #log4j.appender.FILE=org.apache.log4j.RollingFileAppenderlog4j.appender.FILE=org.apache.log4j.DailyRollingFileAppenderlog4j.appender.FILE.File=${catalina.home}/logs/boss.loglog4j.appender.CONSOLE.Threshold=DEBUGlog4j.appender.FILE.Encoding=utf-8#log4j.appender.FILE.MaxFileSize=10MB#log4j.appender.FILE.MaxBackupIndex=100log4j.appender.FILE.layout=org.apache.log4j.PatternLayoutlog4j.appender.FILE.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss,SSS}][%t][%l][%p]: %m%nlog4j.appender.EXECPTION=org.apache.log4j.DailyRollingFileAppenderlog4j.appender.EXECPTION.File=${catalina.home}/logs/error.loglog4j.appender.EXECPTION.Threshold=ERRORlog4j.appender.EXECPTION.Encoding=utf-8#log4j.appender.EXECPTION.MaxFileSize=10MB#log4j.appender.EXECPTION.MaxBackupIndex=100log4j.appender.EXECPTION.layout=org.apache.log4j.PatternLayoutlog4j.appender.EXECPTION.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss,SSS}][%t][%l][%p]: %m%nlog4j.appender.CONSOLE=org.apache.log4j.ConsoleAppenderlog4j.appender.CONSOLE.Target=System.outlog4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayoutlog4j.appender.CONSOLE.layout.ConversionPattern=[%d{HH:mm:ss,SSS}][%-5p][%t][%M] (%F:%L) - %m%nlog4j.appender.Requests=org.apache.log4j.RollingFileAppenderlog4j.appender.Requests.File=${catalina.home}/logs/jotm.loglog4j.appender.Requests.MaxFileSize=100MBlog4j.appender.Requests.MaxBackupIndex=5log4j.appender.Requests.Encoding=utf-8log4j.appender.Requests.layout=org.apache.log4j.PatternLayoutlog4j.appender.Requests.layout.ConversionPattern=%10r [%-5c{1}] %7p - %C{1}.%M(%L) : %m\n#c3p0log4j.logger.com.mchange.v2=ERRORlog4j.logger.com.opensymphony=ERRORlog4j.logger.org.apache=ERRORlog4j.logger.org.springframework=ERRORlog4j.logger.freemarker.cache=ERROR#SqlMap logging configuration...#DEBUG < INFO < WARN < ERROR < FATAL#log4j.logger.com.miri.boss=DEBUGlog4j.logger.com.ibatis=ERRORlog4j.logger.com.ibatis.common.jdbc.SimpleDataSource=ERRORlog4j.logger.com.ibatis.common.jdbc.ScriptRunner=ERRORlog4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=ERROR#log4j.logger.java.sql=INFOlog4j.logger.java.sql.Statement=ERRORlog4j.logger.java.sql.ResultSet=ERRORlog4j.logger.java.sql.PreparedStatement=ERROR#jsonlog4j.org.apache.struts2=ERRORlog4j.logger.org.apache.struts2.json=ERROR#ecsidelog4j.logger.org.ecside.core.TableModelUtils=ERROR# JOTM #log4j.logger.org.objectweb.jotm=ERROR, Requestslog4j.additivity.org.objectweb.jotm=falselog4j.logger.org.objectweb.jotm.jta=ERROR, Requestslog4j.additivity.org.objectweb.jotm.jta=falselog4j.logger.org.objectweb.jotm.recovery=ERROR, Requestslog4j.additivity.org.objectweb.jotm.recovery=falselog4j.logger.org.objectweb.jotm.tests=ERROR, Requestslog4j.additivity.org.objectweb.jotm.tests=false# CAROL #log4j.logger.org.objectweb.carol=ERROR, Requestslog4j.additivity.org.objectweb.carol=falselog4j.logger.org.objectweb.carol.rmi=ERROR, Requestslog4j.additivity.org.objectweb.carol.rmi=falselog4j.logger.org.objectweb.carol.jndi=ERROR, Requestslog4j.additivity.org.objectweb.carol.jndi=false
//value日志级别eroor、info、debug等public void test(String value){final String sArg = LogManager.getRootLogger().getLevel().toString();if (!sArg.equals(value)){//设置日志级别final Level level = Level.toLevel(value);//设置根日志级别LogManager.getRootLogger().setLevel(level);//获取配置文件中的所有log4j对象final Enumeration<org.apache.log4j.Logger> logs = LogManager.getCurrentLoggers();while (logs.hasMoreElements()){final org.apache.log4j.Logger logger = logs.nextElement();//给log4j对象设置级别logger.setLevel(level);}}}
//value日志级别eroor、info、debug等public void test(String value){final String sArg = LogManager.getRootLogger().getLevel().toString();if (!sArg.equals(value)){final Level level = Level.toLevel(value);LogManager.getRootLogger().setLevel(level);final Enumeration<org.apache.log4j.Logger> logs = LogManager.getCurrentLoggers();while (logs.hasMoreElements()){final org.apache.log4j.Logger logger = logs.nextElement();final String loggerName = logger.getName();// 匹配调整部分loggerif (loggerName.contains("java.sql") || loggerName.contains("com.miri.boss") || loggerName.contains("com.ibatis")){logger.setLevel(level);}}}}
log4j.logger.com.miri.boss=DEBUGlog4j.logger.com.ibatis=ERRORlog4j.logger.com.ibatis.common.jdbc.SimpleDataSource=ERRORlog4j.logger.com.ibatis.common.jdbc.ScriptRunner=ERRORlog4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=ERROR#log4j.logger.java.sql=INFOlog4j.logger.java.sql.Statement=ERRORlog4j.logger.java.sql.ResultSet=ERRORlog4j.logger.java.sql.PreparedStatement=ERROR
请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!
技术博客集 - 网站简介:
前后端技术:
后端基于Hyperf2.1框架开发,前端使用Bootstrap可视化布局系统生成
网站主要作用:
1.编程技术分享及讨论交流,内置聊天系统;
2.测试交流框架问题,比如:Hyperf、Laravel、TP、beego;
3.本站数据是基于大数据采集等爬虫技术为基础助力分享知识,如有侵权请发邮件到站长邮箱,站长会尽快处理;
4.站长邮箱:[email protected];
文章归档
文章标签
友情链接