log4j

Mybatis入门程序

别等时光非礼了梦想. 提交于 2020-01-01 12:35:02
1、创建数据库   创建如下的的一个数据库表 2、需求 实现以下功能: 根据用户id查询一个用户信息 根据用户名称模糊查询用户信息列表 添加用户 更新用户 删除用户 3、创建java工程 4、 导入需要的jar包 5、在classpath下面创建log4j.properties文件   Mybatis使用log4j作为日志输出,因此要创建log4j.properties配置文件。 文件内容如下: log4j.rootLogger=DEBUG, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n 6、在classpath下创建SqlMapConfig.xml文件 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">

Exclude a class from a log4j appender

让人想犯罪 __ 提交于 2020-01-01 09:19:17
问题 I have a log4j.properties file that looks something like this: log4j.logger.com.foo=INFO, foo-log log4j.logger.com.foo.BarImpl=INFO, bar-log Usually for classes that match the package structure of com.foo I would want the foo-log appender to be used. However, within that package, I want the BarImpl logs to use the bar-log appender but not the foo-log appender. At the moment, any logs written by BarImpl is handled by both foo-log and bar-log (as expected). How do I get the foo-log appender to

How to change log4j setting during application run?

亡梦爱人 提交于 2020-01-01 08:18:10
问题 Is it possible to change log4j settings during application execution? 回答1: You can use PropertyConfigurator.configureAndWatch to make log4j spawn a thread to periodically check your properties file for changes. Alternatively, you can use JMX described in this post: Change Logging Levels using JMX 回答2: There ways of doing this by making your Log4j accessible through JMX and using a JMX console to control the filters, loggers, levels, appenders etc... I have an example somewhere but I need to

Where does system.out.println in tomcat under windows gets written?

∥☆過路亽.° 提交于 2020-01-01 08:07:41
问题 I am using a third party library (cannot modify it) that uses for logging system.out.println statements. The output shows fine in the console but I am not able to retrieve those information in the catalina[...].log file? Is it possible to send those to log4j? 回答1: System.out.println() prints out to stdout. Therefore, if you want to see these statements in a log file, you can just redirect stdout where you want it in the Tomcat startup script. 回答2: When running Tomcat on unixes, the console

include log4j properties file in hibernate to show query with value instead of question mark

百般思念 提交于 2020-01-01 07:41:10
问题 I have crearte log4j.properties file like below: log4j.logger.org.hibernate=INFO, hb log4j.logger.org.hibernate.SQL=DEBUG log4j.logger.org.hibernate.type=TRACE log4j.logger.org.hibernate.hql.ast.AST=info log4j.logger.org.hibernate.tool.hbm2ddl=warn log4j.logger.org.hibernate.hql=debug log4j.logger.org.hibernate.cache=info log4j.logger.org.hibernate.jdbc=debug log4j.appender.hb=org.apache.log4j.ConsoleAppender log4j.appender.hb.layout=org.apache.log4j.PatternLayout log4j.appender.hb.layout

Logs are filling up with httpclient.wire.content dumps. How can I turn it off?

烈酒焚心 提交于 2020-01-01 05:21:05
问题 My catalina logs are filling up with gobs of statements like: /logs/catalina.out:2010-05-05 02:57:19,611 [Thread-19] DEBUG httpclient.wire.content - >> "[0x4] [0xc][0xd9][0xf4][0xa2]MA[0xed][0xc2][0x93][0x1b][0x15][0xfe],[0xe]h[0xb0][0x1f][0xff][0xd6][0xfb] [0x8f]O[0xd4][0xc4]0[0xab][0x80][0xe8][0xe4][0xf2][\r]I&[0xaa][0xd2]BQ[0xdb](zq[0xcd]ac[0xa8] on and on forever. I searched every config file in both tomcat and apache for the statements that purportedly turn this on as described here:

How to have Spring boot use a log4j.xml configuration file?

☆樱花仙子☆ 提交于 2020-01-01 05:03:12
问题 I have a simple Spring Boot application that builds to a jar file. I have a log4j.xml file in src/main/resources/log4j.xml that looks like this (basic sample file from the log4j docs): <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="stdout" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <!-- Pattern to output the caller's

logging connection pooling for org.apache.commons.dbcp.BasicDataSource with spring

爱⌒轻易说出口 提交于 2020-01-01 04:22:27
问题 I am trying to log connection pooling for org.apache.commons.dbcp.BasicDataSource using log4j I am using spring framework for dao layer injection. When I saw code inside org.apache.commons.dbcp.BasicDataSource , Logger is not used .So it seems impossible to log pooling message for me. But again I saw this link http://forum.springsource.org/showthread.php?38306-Connection-Pooling-debug-info. Some people were saying to put log4j.category.org.apache.dbcp=DEBUG . But I could not find the right

springboot-日志框架

旧街凉风 提交于 2020-01-01 03:14:27
1、日志框架简介   对于一个应用程序来说,日志的记录是必不可少的一部分。线上的问题追踪,基于日志业务逻辑统计分析等都离不开日志。java领域存在许多已经写好成熟的日志框架,经常使用的有JCL(jakarta Commons logging), SLF4J(simple Logging facade java), jboss-logging, log4j, JUL(java.util.logging), log4j2, logback等。   从实现来说,java框架分为两种,一种是日志门面(日志的抽象层)和日志实现,所以我们在选日志框架的时候,一般都是选一个日志门面,然后再选一个日志实现。其中,日志门面包括JCL(jakarta Commons logging), SLF4J(simple Logging facade java), jboss-logging等,而日志实现则包括 log4j, JUL(java.util.logging), log4j2, logback。    Spring框架默认使用的就是JCL, 实现层可以选log4j或者log4j2,而Spring boot选用的是 SLF4J和logback 2、日志框架之间的关系    因为日志框架之间没用形成统一的接口,所我们在选日志门面和日志实现的时候不能选错。而日志抽象接口也基本分为两大阵营了,一个是JCL

SpringBoot日志管理

独自空忆成欢 提交于 2020-01-01 03:13:46
一、简介 小张;开发一个大型系统; 1、System.out.println("");将关键数据打印在控制台;去掉?写在一个文件? 2、框架来记录系统的一些运行时信息;日志框架 ; zhanglogging.jar; 3、高大上的几个功能?异步模式?自动归档?xxxx? zhanglogging-good.jar? 4、将以前框架卸下来?换上新的框架,重新修改之前相关的API;zhanglogging-prefect.jar; 5、JDBC---数据库驱动; 写了一个统一的接口层;日志门面(日志的一个抽象层);logging-abstract.jar; 给项目中导入具体的日志实现就行了;我们之前的日志框架都是实现的抽象层; SpringBoot:底层是Spring框架,Spring框架默认是用JCL;‘ ​ ==SpringBoot选用 SLF4j和logback;== 二、SLF4J 使用 1.如何在系统中使用SLF4j https://www.slf4j.org 以后开发的时候,日志记录方法的调用,不应该来直接调用日志的实现类,而是调用日志抽象层里面的方法;给系统里面导入slf4j的jar和 logback的实现jar import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class HelloWorld