log4j

SpringMVC+Spring+mybatis项目从零开始--Spring mybatis mysql配置实现

☆樱花仙子☆ 提交于 2020-01-12 23:26:30
上一章我们把SSM项目结构已搭建( SSM框架web项目从零开始--分布式项目结构搭建 )完毕,本章将实现Spring,mybatis,mysql等相关配置。 1. 外部架包依赖引入 外部依赖包引入可以根据相关包名从 网站:http://mvnrepository.com/ 获取依赖引入语句结构。 SSM项目详细依赖包请见ssm-parent中的pom.xml文件。 1.1 spring框架依赖包引入 spring-context spring-beans spring-jdbc spring aspects spring-webmvc 1.2 spring-mybatis依赖包引入 mybatis mybatis-spring 1.3 数据库依赖包引入 mysql-connector-java druid 1.4 redis依赖包引入 jedis 1.5 web相关依赖包引入 jstl servlet-api jsp-api Jackson-databind 1.6 其他日志和公共包依赖引入 slf4j-log4j12 junit commons-langs commons-io 2. 各项目间依赖关系以及架包引入 ssm-parent实现了所有外部依赖包引入 (1)ssm-commons 实现公共的组件,工具类等 (2)ssm-manager 实际业务管理工程,聚合工程,

异常和Log4j

拜拜、爱过 提交于 2020-01-12 02:33:39
一.生活中的异常一路畅通但是,异常情况迟早要发生!堵车!撞车! 二.什么是异常 异常是指在程序的运行过程中所发生的不正常的事件,它会中断正在运行的程序 生活中面对异常通常会这样处理 绕行或者等待 请求交警解决 生活中,根据不同的异常进行相应的处理,而不会就此中断我们的生活 三.Java的异常处理是通过5个关键字来实现的 try、catch、 finally、throw、throws 捕获异常 执行可能产生异常的代码 无论是否发生异常, 捕获异常 代码总能执行 声明异常 抛出异常 四.常见的异常类型 异常层次结构的父类 算术错误情形,如以零作除数 数组下标越界 尝试访问 null 对象成员 不能加载所需的类 方法接收到非法参数 五.Log4J 在项目中加入log4j的JAR文件 创建log4j.properties文件 配置日志信息 使用log4j记录日志信息 来源: CSDN 作者: athga 链接: https://blog.csdn.net/athga/article/details/103826302

log4j2之简化封装,告别静态成员变量

心已入冬 提交于 2020-01-12 00:28:45
注 本文是使用 slf4j + log4j2 示例,由于 slf4j 只是一个统一接口包,log4j / log4j2 / logback 等都是有其实现类,所以本文中是以 slf4j 为例。若有朋友坚持不使用 slf4j ,则将代码中 slf4j 相关的都做对应更改即可,并不麻烦。 序 一般情况下,每当我们使用 slf4j 等log组件时,都是在需要记载日志的类中,创建一个静态的 Logger 成员变量,然后调用 debug,info,error 等方法。这就意味着我们每一个要记载日志的类,都需要先定义一个静态的成员变量,这样才打印出正确的前缀(带有类名称) 一、现状 我们以码云中几个热门的java项目为例(下面的代码片段都是 star 超过 500+ 的项目) public class DepartController { private static final Logger logger = Logger.getLogger(DepartController.class); ... method() { logger.info("some things!"); } } @Controller public class LoginController extends BaseController { private static final Logger LOGGER =

Hibernate suppress info messages

六眼飞鱼酱① 提交于 2020-01-11 10:46:33
问题 So I am not very experience in Java and I am creating a simple test project with Hibernate but I am gettinga lot of INFO messages on the console that I want to suppress. I am creating a Java SE program in Eclipse. Now as I think I understand it then I need to control this in a log4j.properties file, and I seem to have found the appropiate config to use, but the problem is that it appears that it makes no difference! My guess is that my log4j.properties file is somehow not being read. But all

Hibernate suppress info messages

守給你的承諾、 提交于 2020-01-11 10:46:14
问题 So I am not very experience in Java and I am creating a simple test project with Hibernate but I am gettinga lot of INFO messages on the console that I want to suppress. I am creating a Java SE program in Eclipse. Now as I think I understand it then I need to control this in a log4j.properties file, and I seem to have found the appropiate config to use, but the problem is that it appears that it makes no difference! My guess is that my log4j.properties file is somehow not being read. But all

String concatenation performance in Log4j

ぃ、小莉子 提交于 2020-01-11 09:21:07
问题 I have often heard people saying that its one of the best practices to avoid String Concatenation and use {} instead while logging. I was looking into the Log4j code to see how they have handled this and figured that they are doing something similar. Here is a snippet of format() method which takes the pattern and arguments and returns the message to be logged. /** * Formats arguments using SLF4J-like formatter. * @param pattern pattern, may be malformed. * @param arguments arguments. *

Where can i programatically find where the log4j log files are stored?

孤街醉人 提交于 2020-01-11 08:28:08
问题 Relative paths are used in the log4j.properties file. How can i find the absolute path programatically where logs are stored? 回答1: From: http://www.gunith.com/2010/11/how-to-get-the-file-path-of-a-log4j-log-file/ Assume the log4j.properties file is as below, log4j.logger.migrationlog = INFO, migration log4j.appender.migration = org.apache.log4j.RollingFileAppender log4j.appender.migration.File = C:/work/log/migration.log log4j.appender.migration.MaxFileSize=20MB log4j.appender.migration

Creating log4j log file for each run with Date and timestamp

独自空忆成欢 提交于 2020-01-11 05:07:21
问题 All, it seems like this question is posted multiple times but still i haven't got proper solution for my problem. I referred this and this but its not working. As per below property file, a new file is created everytime with date in it But I want to create a log file with below format and need to be generated each and everytime my application is executed, logFileName_MM_DD_YY-HH_MM_SS.log (or) logFileName.log_YYYY_MM_DD_HH_MM_SS # Root logger option log4j.rootLogger=INFO,file,stdout #

hadoop 2.7.3 (hadoop2.x)使用ant制作eclipse插件hadoop-eclipse-plugin-2.7.3.jar

≯℡__Kan透↙ 提交于 2020-01-11 04:43:20
  为了做mapreduce开发,要使用eclipse,并且需要对应的Hadoop插件hadoop-eclipse-plugin-2.7.3.jar,首先说明一下,在hadoop1.x之前官方hadoop安装包中都自带有eclipse的插件,而如今随着程序员的开发工具eclipse版本的增多和差异,hadoop插件也必须要和开发工具匹配,hadoop的插件包也不可能全部兼容.为了简化,如今的hadoop安装包内不会含有eclipse的插件.需要各自根据自己的eclipse自行编译. 1. 环境准备   使用ant制作自己的eclipse插件,介绍一下我的环境和工具 ( 安装路径根据自己 )   系统: 64bit Ubuntu 14.04,(系统不重要Win也可以,方法都一样)   JDK 版本: jdk-7u80-linux-x64.tar.gz 安装路径: /usr/lib/jvm   eclipse 版本: ide工具eclipse-jee-mars-2-linux-gtk-x86_64.tar.gz 安装路径: /home/hadoop/   hadoop 版本: hadoop-2.7.3.tar.gz 安装路径:/usr/local   ant(这个也随意,二进制安装或者apt-get安装都可以,配置好环境变量) , 我的 ant 版本是1.9.3 , 有的是 1.9.7

Configuring multiple log files in log4j while using categories

a 夏天 提交于 2020-01-11 03:33:10
问题 Here's what I'm trying to do: I want 2 log files: The first logs INFO level and up for all parts of the applications but also logs DEBUG and up for some packages. The second only logs ERROR and up across all packages. I'm sure this is probably trivial but I can't quite figure it out. Here is the configuration file I am currently using: log4j.rootLogger=INFO,console,R #console appender log4j.appender.console = org.apache.log4j.ConsoleAppender log4j.appender.console.layout = org.apache.log4j