log4j

MyBatis打印输出SQL语句

心不动则不痛 提交于 2020-01-17 00:59:40
Hibernate是可以配置 show_sql 显示 自动生成的SQL 语句,用 format_sql 可以格式化SQL 语句,但如果用 mybatis 怎么实现这个功能呢?如果你搜索看一下,基本都是通过配置日志来实现的,比如配置我们最常用的 log4j.properties 来实现。 首页我们创建一个 java 工程叫作:mybatis12,内容与之前 Mybatis+Spring 差不多,实现一个通过指定用户ID并读取其订单列表,来观察SQL的执行情况。其工程目录结构如下: log4j.properties 内容如下: # by yiibai.com log4j.rootLogger=debug,stdout,logfile log4j.appender.stdout=org.apache.log4j.ConsoleAppender #log4j.appender.stdout.Target=System.err log4j.appender.stdout.layout=org.apache.log4j.SimpleLayout log4j.appender.logfile=org.apache.log4j.FileAppender log4j.appender.logfile.File=C:/mybatis_show_sql.log log4j.appender

Log4j2的基本使用

ⅰ亾dé卋堺 提交于 2020-01-16 23:47:01
  Log4j2是Log4j1.x的的升级版,其中也有很大的不同,最大的区别就是由以前的properties配置文件改为xml/json/yaml配置文件。   其中配置文件的位置官方说明如下: Log4j will inspect the "log4j.configurationFile" system property and, if set, will attempt to load the configuration using the ConfigurationFactory that matches the file extension. If no system property is set the YAML ConfigurationFactory will look for log4j2-test.yaml or log4j2-test.yml in the classpath. If no such file is found the JSON ConfigurationFactory will look for log4j2-test.json or log4j2-test.jsn in the classpath. If no such file is found the XML ConfigurationFactory will look for

Log4j2日志配置

点点圈 提交于 2020-01-16 23:42:53
一、Log4j2 Maven配置 Log4j2的性能高于log4j与logback,在项目中建议使用Log4j2,其依赖如下(目前最新版本为2.6.2): <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>2.6.2</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.6.2</version> </dependency> 二、log4j2.xml文件配置 log4j2.xml的配置文件放在classpath下就会被自动加载,其配置如下: <?xml version="1.0" encoding="UTF-8"?> <!-- status : 这个用于设置log4j2自身内部的信息输出,可以不设置,当设置成trace时,会看到log4j2内部各种详细输出 monitorInterval : Log4j能够自动检测修改配置文件和重新配置本身, 设置间隔秒数。 --> <Configuration status="WARN"

springMVC + Spring + MyBatis 整合

一曲冷凌霜 提交于 2020-01-16 17:54:31
整理下SSM(基于注解)的整合 1. web.xml 配置文件 1 <?xml version="1.0" encoding="UTF-8"?> 2 <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 5 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 6 7 <!-- log4j 配置 --> 8 <context-param> 9 <param-name>log4jConfigLocation</param-name> 10 <param-value>classpath:log4j.properties</param-value> 11 </context-param> 12 <context-param> 13 <param-name>log4jRefreshInterval</param-name> 14 <param-value>60</param-value> 15 </context-param> 16 <listener>

centos 7磁盘空间满了导致redis cluster问题和kafka的问题

你说的曾经没有我的故事 提交于 2020-01-16 17:39:53
发现java的日志里面老是报错如下日志,还有kafka的消费者收不到消息,看来docker logs kafka日志如下: 原因估计是12月23日那天磁盘空间满了,导致redis和kafka异常 解决方法: 重启了redis的这个节点172.18.144.94:7006 重启了kafka就ok了 如下是redis cluster的报错 2020-01-16 17:10:00.098 pool-8-thread-3 ERROR com.hp.nova.common.todayuseronline.UserOnlineScheduleJob.userOnlineScheduleJob(UserOnlineScheduleJob.java:73) - java.lang.NumberFormatException: For input string: "redis.clients.jedis.exceptions.JedisMovedDataException: MOVED 9139 172.18.144.94:7006" at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043) ~[?:1.8.0_191] at sun.misc.FloatingDecimal.parseDouble

Zookeeper not logging as per directory path in log4j

自闭症网瘾萝莉.ら 提交于 2020-01-16 14:55:33
问题 I have written a small main class which will instantiate a zookeeper server. public class ZooKeeper { public static void main(String[] args) { QuorumPeerMain qp = new QuorumPeerMain(); QuorumPeerConfig config = new QuorumPeerConfig(); try { config.parse("D:\\kafka_2.12-2.2.0\\config\\zookeeper.properties"); qp.runFromConfig(config); System.out.println("Started...."); } catch (Exception e) { e.printStackTrace(); } } } I give a parameter in -Dlog4j.debug -Dlog4j.configuration=file:D:\zookeeper

Zookeeper not logging as per directory path in log4j

筅森魡賤 提交于 2020-01-16 14:55:03
问题 I have written a small main class which will instantiate a zookeeper server. public class ZooKeeper { public static void main(String[] args) { QuorumPeerMain qp = new QuorumPeerMain(); QuorumPeerConfig config = new QuorumPeerConfig(); try { config.parse("D:\\kafka_2.12-2.2.0\\config\\zookeeper.properties"); qp.runFromConfig(config); System.out.println("Started...."); } catch (Exception e) { e.printStackTrace(); } } } I give a parameter in -Dlog4j.debug -Dlog4j.configuration=file:D:\zookeeper

%HOSTNAME% value is “unknown” in rsyslog

别说谁变了你拦得住时间么 提交于 2020-01-16 13:12:13
问题 The Gist Where does rsyslog get the value of %HOSTNAME%? Why does an application served by Tomcat have the correct %HOSTNAME%, but a console application with the same configuration has "unknown" as the hostname? We're using rsyslog on an EC2 instance and we're trying to send our logs out to loggly. If I tail -f the log messages, I can see the log in the default format including date, hostname, tag, and message. If I use logger "message" then I see a correct log entry both in the console and

log4j2 extending Logger class

我的梦境 提交于 2020-01-16 05:25:26
问题 I am trying to migrate from Log4j 1.7 to Log4j2.4 In 1.7, I as creating AppLogger class by extending org.apache.log4j.Logger and using extending debug/error/fatal Methods e.g., public void error(Object message) { Object error = message; if (message instanceof Exception) { Exception e = (Exception) message; StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); error = sw.toString(); } super.error(error); } But in Log4j 2.x, I am not able to extend the class org.apache

Multiple files with Log4j

瘦欲@ 提交于 2020-01-16 00:34:09
问题 I'm using log4j to log several informations. I'd like to separate these infos into multiple files. My configuration file is similar to this: #logger_1 log4j.logger.logger_1=debug, logger_1_File log4j.appender.logger_1_File=org.apache.log4j.RollingFileAppender log4j.appender.logger_1_File.layout=org.apache.log4j.PatternLayout log4j.appender.logger_1_File.layout.ConversionPattern=%d{ABSOLUTE} %m%n log4j.appender.logger_1_File.File=${webinf}/logs/logger1/logger1.log log4j.appender.logger_1_File