log4j

log4j----slf4j---logback从知道到编写配置文件

≡放荡痞女 提交于 2019-12-05 07:13:27
明天要去学习的 1.学习springBoot的自动装配,并且知道spring是如何自动去加载log4j的流程 https://blog.csdn.net/satomiyo/article/details/100040235 log4j配置文件 了解日志-->slf4j的介绍-->log4j的介绍-->logback的介绍-->springboot中slf4j+log4j的使用-->springboot中slf4j+logback的使用 一、前言 我觉得能够加强自己的开发能力,首先必须学会去配置一些文件,而不是crud。在springBoot项目中,一般会有log4j.properties的配置文件,该配置文件是记录项目中的日志的配置信息。 日志是一个项目中必不可少的灵魂,没有日志的项目是没有灵魂的,因此掌握基础的日志编写是非常有必要的。 二、为什么需要日志 我们最开始使用的是System.out.prinlt()进行输出我们的调代码的信息,用来监控具有什么信息,System.out.println()其实是对业务无关的代码,这些对业务无关的代码都是对业务代码的一些intercupt。 我们必须要明确,日志不仅仅System.out.prinlt(s) ,s的信息,同时日志包括一些额外的上下文,上下文信息是非常重要的,这些信息具有 访问时间、对应的类、行、产生的线程等

springboot项目大量打印debug日志问题

谁都会走 提交于 2019-12-05 06:59:01
目前,java下应用最广泛的日志系统主要就是两个系列: log4j和slf4j+logback 。 其中,slf4j只包含日志的接口,logback只包括日志的具体实现,两者加起来才是一个完整的日志系统。Log4j则同时包含了日志接口和实现。 这两套日志系统之间有可以相互兼容的组件,分别是slf4j-log4j12和 log4j-over-slf4j,引入之后就可以用log4j打出slf4j接口的日志,或者用logback打出log4j接口的日志。 背景知识介绍到这里,再简单说一下标题里提到的问题。问题的现象就是我们在war包里配置了log4j的日志级别为info, 但在catalina里却一直在打大量的debug日志。初看现象肯定很诡异,前期各种研究tomcat配置也没什么头绪。直到磁盘压力太大,去看jstack发现大量进程是等待在Logback代码中,才发现之前关注错了重点。再去具体了解了java下的日志系统后,问题也就很明了了。 先把几个事实摆出来: 1. 打出的debug日志都是用slf4j写的,根据堆栈得知logback具体执行了日志打印 2. logback在无配置文件时默认debug级别 3. 我们的war包中同时包含logback,log4j和slf4j-log4j12 4. Slf4j无法主动选择具体的日志实现 想必看到这里,大家也明白了问题所在。根据我们引入的包

log4j.properties模板

自作多情 提交于 2019-12-05 06:39:49
# Global logging configuration log4j.rootLogger=DEBUG, stdout # Console output... log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n 来源: https://www.cnblogs.com/tsvv-plus/p/11911076.html

log4j:ERROR Error occured while converting date

故事扮演 提交于 2019-12-05 06:36:19
I found this exception in my logs: log4j:ERROR Error occured while converting date. java.lang.NullPointerException at java.lang.System.arraycopy(Native Method) at java.lang.AbstractStringBuilder.getChars(AbstractStringBuilder.java:328) at java.lang.StringBuffer.getChars(StringBuffer.java:201) at org.apache.log4j.helpers.ISO8601DateFormat.format(ISO8601DateFormat.java:130) at java.text.DateFormat.format(DateFormat.java:316) at org.apache.log4j.helpers.PatternParser$DatePatternConverter.convert(PatternParser.java:443) at org.apache.log4j.helpers.PatternConverter.format(PatternConverter.java:65)

Correct usage Of LOG4J in Spring Framework Via DI

我的未来我决定 提交于 2019-12-05 05:58:58
I am trying to use Log4j as part of the Spring Framework, as far as i understand through the use of a an appropriate bean the system is supposed to map a singleton instance accessible in the code while mapping the logging depth automatically to the class Similar to the normal use of Log4J as in Logger log = Logger.getLogger(getClass()); i have been using the following Spring bean definition <bean id="log4jInitialization" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> <property name="targetClass" value="org.springframework.util.Log4jConfigurer" /> <property name=

option for ant junit task to dump console output on-the-fly

纵饮孤独 提交于 2019-12-05 05:51:07
I have an issue when using the Ant junit task to launch my non-regression tests: the console output is only dumped when the test end. It causes some OOM when there are too many logs with respect to the process Xmx and means that if the process dies (or is killed by a watchdog) before its end the logs are lost. <junit fork="true" forkmode="once" timeout="1200000" haltonfailure="no" outputtoformatters="yes" failureProperty="test.failure" dir="${project.test.dir}"> <junit-opts/> <formatter type="xml" /> <formatter type="brief" /> <test name="${project.test.suite}" todir="${report.junit.dir}"

zookeeper启动失败导致项目不能运行

*爱你&永不变心* 提交于 2019-12-05 05:44:06
1 保证zookeeper正常启动 启动zookeeper(换行处键入回车) cd zookeeper- 3.4 . 6 cd bin ./zkServer.sh start 启动 ./zkServer.sh status 查看状态 启动成功的提示: 如果提示Starting zookeeper … already running as process ……,表示之前有启动过zookeeper,但是没有正常关闭。 进入和bin同层级的data目录下,删除zookeeper_server.pid文件,再执行启动命令。 cd .. 退回上级目录 cd data rm -f zookeeper_server.pid cd .. cd bin ./zkServer.sh start 目录结构: 2 启动远程 192.168.37.138 上的Tomcat cd apache-tomcat- 7.0 . 47 cd bin ./shutdown.sh 如果之前启动了Tomcat,就先关闭进程 ./startup.sh 启动Tomcat 3 保证本机可以远程访问dubbo监控界面,并且能够看到服务的提供者和消费者。(需要安装dubbo监控中心) 本机 192.168.37.159 远程 192.168.37.138 在浏览器访问 http://192.168.37.138:8080/dubbo

Log4j not finding custom appender using a property file

寵の児 提交于 2019-12-05 05:40:27
I'm trying to configure log4j in an Eclipse plugin project using the following XML property file, that includes a custom appender called EclipseLoggingAppender: <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true"> <appender name="eclipseErrorView" class="com.lior.ibd.utils.logging.EclipseLoggingAppender"/> <appender name="console" class="org.apache.log4j.ConsoleAppender"> <param name="Target" value="System.out"/> <layout class="org.apache.log4j.PatternLayout"> <param name=

log4j.properties not working in executable jar

隐身守侯 提交于 2019-12-05 05:25:25
I'm using eclipse and I have placed log4j.properties in the project directory and I access it by calling PropertyConfigurator.configure("log4j.properties"); this works fine in Eclipse, but when I extract the project as an executable Jar and run it on another machine, I get an error saying that it can't find log4j.properties. What is the solution to this? What's happening PropertyConfigurator.configure(String) loads and reads a file from the file-system. Your property file is in the project directory, which would be the "current working directory" when you run from eclipse. Once you've packaged

Log4j not working

…衆ロ難τιáo~ 提交于 2019-12-05 05:22:54
I using common logging and jboss eap 6.2 in java application, log file is creating but empty and hibernate log also not working. This is my jboss-deployment-structure.xml <jboss-deployment-structure> <deployment> <exclusions> <module name="org.apache.commons.logging"/> <module name="org.apache.log4j"/> </exclusions> </deployment> <sub-deployment name="abc.war"> <exclusions> <module name="org.apache.log4j"/> <module name="org.apache.commons.logging"/> </exclusions> </sub-deployment> </jboss-deployment-structure> and this is my log4j.properties log4j.rootLogger=DEBUG, FILE log4j.appender.FILE