log4j

How to log in different file? log4j2

左心房为你撑大大i 提交于 2019-12-10 19:58:22
问题 I need to log all info to info.log, all warn to warn.log etc and all my logs to all.log. I've been create a log4j2.xml configuration. <?xml version="1.0" encoding="UTF-8"?> <configuration monitorInterval = "3" status = "info"> <appenders> <File name="ALL_LOG" fileName="logs/all.log"> <PatternLayout pattern="%d{ISO8601} [%-5p] (%F:%L) - %m%n"/> </File> <File name="FILE_ERROR" fileName="logs/error.log"> <PatternLayout pattern="%d{ISO8601} [%-5p] (%F:%L) - %m%n"/> </File> <File name="FILE_INFO"

Customising log4j logging for sensitive data

断了今生、忘了曾经 提交于 2019-12-10 18:52:36
问题 I have a class which contains sensitive information (Credit card info, phone numbers etc). I want to be able to pass this class to log4j, but have it obscure certain information. If I have a class UserInformation which has getPhoneNumber, getCreditCardNumber methods, how would I customise log4j or this class so that it will obscure the numbers correctly. I want the credit card number to be output as xxxx-xxxx-xxxx-1234 and the phone number to be output as xxxx-xxx-xxx given that these would

Proguard - Can't find any super classes

纵饮孤独 提交于 2019-12-10 18:43:40
问题 I'm getting this error: Unexpected error while performing partial evaluation: Class = [org/apache/log4j/chainsaw/Main] Method = [<init>()V] Exception = [java.lang.IllegalArgumentException] (Can't find any super classes of [org/apache/log4j/chainsaw/LoadXMLAction] (not even immediate super class [javax/swing/AbstractAction])) Error: Can't find any super classes of [org/apache/log4j/chainsaw/LoadXMLAction] (not even immediate super class [javax/swing/AbstractAction]) Part of my proguard

springboot2 log4j 2 配置

北慕城南 提交于 2019-12-10 18:20:59
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 通过pom配置log4j 2所需要的依赖 去掉项目本身的日志框架换上log4j2依赖 创建log4j 2 xml配置文件 配置读取log4j2的配置文件路径 log4j2-dev.xml <?xml version="1.0" encoding="UTF-8" ?> <!--status 是否记录log4j2本身的event信息默认OFF print level:TRACE < DEBUG < INFO <WARN < ERROR < FATAL monitorInterval 300秒检查一下配置,如果有变化不需要重启服务,自动更新--> <Configuration package="com.megatron" status="TRACE" monitorInterval="300"> <Properties> <!--自定义指定路径--> <Property name="LOG_HOME">/lv_data/logs/java/</Property> <Property name="PATTERN_FORMAT">%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread][%-5level][%l]:%m%n</Property> </Properties> <Appenders> <!-

MyBatis系列-Mybatis源码之 Log的实现流程(4)

孤街醉人 提交于 2019-12-10 18:15:59
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 本篇文章内容 Mybatis的日志如何配置,如何加载配置? 核心接口和实现类 如何实现只打印SQL,不打印结果集? 如何实现只打印部分Mapper的SQL? 官方文档: http://www.mybatis.org/mybatis-3/zh/logging.html 从配置开始 我们从Mybatis配置文件中的日志配置开始,来看看它到底是怎么实现的 <configuration> <settings> <setting name="logImpl" value="NO_LOGGING"/> </settings> </configuration> 从测试代码入手 @Test public void shouldReadLogImplFromSettings() throws Exception { Reader reader = Resources.getResourceAsReader("org/apache/ibatis/logging/mybatis-config.xml"); new SqlSessionFactoryBuilder().build(reader); reader.close(); Log log = LogFactory.getLog(Object.class); log.debug(

MyBatis 之输出 sql 日志

血红的双手。 提交于 2019-12-10 18:15:32
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 两种方式 使用标准日志输出 <configuration> <settings> <setting name=" logImpl " value=" STDOUT_LOGGING " /> ====》System.out.pringln. </settings> </configuration> 使用log4j日志输出 <configuration> <settings> <setting name=" logImpl " value=" LOG4J " /> </settings> </configuration> logImpl 指定 MyBatis 所用日志的具体实现, 未指定时将自动查找 。 SLF4J | LOG4J | LOG4J2 | JDK_LOGGING | COMMONS_LOGGING| STDOUT_LOGGING | NO_LOGGING Mybatis 的内置日志工厂提供日志功能,内置日志工厂将日志交给以下其中一种工具作代理: SLF4J Apache Commons Logging Log4j 2 Log4j JDK logging MyBatis 内置日志工厂基于运行时自省机制选择合适的日志工具。它会使用第一个查找得到的工具(按上文列举的顺序查找)。如果一个都未找到

springboot2 log4j 2 配置Mongodb3

家住魔仙堡 提交于 2019-12-10 18:14:00
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 第一步、查看正经的配置保证该有的引入包一致 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <!--使用log4j2需要去除loggin--> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions> </dependency> <!--log4j2--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-log4j2</artifactId> </dependency> <!-- https://mvnrepository.com/artifact/org.mongodb/mongo-java-driver --> <dependency> <groupId>org.mongodb<

mybatis-Logging

馋奶兔 提交于 2019-12-10 18:10:32
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> Logging Mybatis内置的日志工厂提供日志功能,具体的日志实现有以下几种工具: SLF4J Apache Commons Logging Log4j 2 Log4j JDK logging 具体选择哪个日志实现工具由MyBatis的内置日志工厂确定。它会使用最先找到的(按上文列举的顺序查找)。 如果一个都未找到,日志功能就会被禁用。 不少应用服务器的classpath中已经包含Commons Logging,如Tomcat和WebShpere, 所以MyBatis会把它作为具体的日志实现。记住这点非常重要。这将意味着,在诸如 WebSphere的环境中——WebSphere提供了Commons Logging的私有实现,你的Log4J配置将被忽略。 这种做法不免让人悲催,MyBatis怎么能忽略你的配置呢?事实上,因Commons Logging已经存 在了,按照优先级顺序,Log4J自然就被忽略了!不过,如果你的应用部署在一个包含Commons Logging的环境, 而你又想用其他的日志框架,你可以通过在MyBatis的配置文件mybatis-config.xml里面添加一项setting(配置)来选择一个不同的日志实现。 <configuration> <settings> ...

mybatis初步之----日志记录

别说谁变了你拦得住时间么 提交于 2019-12-10 18:05:00
1、mybatis日志优先级 SLF4J Apache Commons Logging Log4j 2 Log4j JDK logging 指定某种日志(相应日志实现必须存在,启动时调用,未测试) org.apache.ibatis.logging.LogFactory.useSlf4jLogging(); org.apache.ibatis.logging.LogFactory.useLog4JLogging(); org.apache.ibatis.logging.LogFactory.useJdkLogging(); org.apache.ibatis.logging.LogFactory.useCommonsLogging(); org.apache.ibatis.logging.LogFactory.useStdOutLogging(); 2、对于xml配置的sql语句输出(只使用log4j,测试可以使用) <mapper namespace="sysBackTask"> <select id="selectSysBackTask" parameterType="int" resultType="SysBackTask" > select * from sys_back_task where id = #{id} </select> </mapper> 配置为:

【原】配置Log4j,使得MyBatis打印出SQL语句

大城市里の小女人 提交于 2019-12-10 17:54:44
官网日志: mybatis官网日志文档 日志格式请参考: Pattern Layout 下对应的:Patterns规则。 【配置步骤】 一、mybatis-config.xml 设置MyBatis的Setting(非必须,不同环境下,可能不需要该设置)。原因如下: Mybatis通过日志工厂提供日志信息,Mybatis内置的日志模版是log4j,commons.log,jdk log也可以通过slf4j简单日志模版结合log4j使用日志信息输出.具体选择哪个日志实现由MyBatis的内置日志工厂确定。 它会使用最先找到的(按上文列举的顺序查找) 。 如果一个都未找到,日志功能就会被禁用。 不少应用服务器的classpath中已经包含Commons Logging,如Tomcat和WebShpere, 所以MyBatis会把它作为具体的日志实现 。 记住这点非常重要。这意味着 ,在诸如 WebSphere的环境中——WebSphere提供了Commons Logging的私有实现,你的Log4J配置将被忽略。 不过,如果你的应用部署在一个包含Commons Logging的环境, 而你又想用其他的日志框架,你可以做如下配置. 1. 配置日志输出方式是log4j  在“src/main/java/resources”目录下,创建mybatis-config.xml文件,并且输入下列内容