- log4j配置
yy爱yy
#log4j.rootLogger配置的是大于等于当前级别的日志信息的输出#log4j.rootLogger用法:(注意appenderName可以是一个或多个)#log4j.rootLogger=日志级别,appenderName1,appenderName2,....#log4j.appender.appenderName2定义的是日志的输出方式,有两种:一种是命令行输出或者叫控制台输出,另一
- spring如何整合druid连接池?
惜.己
springspringjunit数据库javaidea后端xml
目录spring整合druid连接池1.新建maven项目2.新建mavenModule3.导入相关依赖4.配置log4j2.xml5.配置druid.xml1)xml中如何引入properties2)下面是配置文件6.准备jdbc.propertiesJDBC配置项解释7.配置druid8.测试spring整合druid连接池1.新建maven项目打开IDE(比如IntelliJIDEA,Ecl
- 微服务分布式架构中,如何实现日志链路跟踪?
2401_84048542
程序员架构微服务分布式
MDC(MappedDiagnosticContext,映射调试上下文)是log4j和logback提供的一种方便在多线程条件下记录日志的功能。MDC可以看成是一个与当前线程绑定的Map,可以往其中添加键值对。MDC中包含的内容可以被同一线程中执行的代码所访问。当前线程的子线程会继承其父线程中的MDC的内容。当需要记录日志时,只需要从MDC中获取所需的信息即可。MDC的内容则由程序在适当的时候保存
- 【数据结构】字符串与JSON字符串、JSON字符串及相应数据结构(如对象与数组)之间的相互转换
理想青年宁兴星
数据结构数据结构jsonjava
前言:下面打印日志用的是FastJSON依赖库中的@Log4j2。依赖:com.alibabafastjson1.2.80目录普通字符串->json字符串json字符串->普通字符串java对象->json字符串json字符串->java对象普通字符串->json字符串代码:publicstaticvoidmain(String[]args){Strings="ningxingxing";Stri
- springboot整合Logback
星空下夜猫子
springbootlogback后端
Logback介绍描述Logback是由log4j创始人设计的另外一种开源日志组件,性能比log4j要好。相对是一个可靠、通用、快速而又灵活的Java日志框架。Logback主要分三个模块1、logback-core:其他两个模块的基础模块2、logback-classic:它是log4j的一个改良版本,同时它完整实现了slf4j。API,可以很方便地更换成其它日志系统,如log4j或JDK14L
- log4jdbc使用介绍
leechiwi
log4jdbc
0前言使用java进行数据库操作时最痛苦的莫过于拼接SQL语句。在实际运行时往往需要查看实际生成的SQL语句和实际传入的参数,或许还会有查看SQL执行时间等的需求。无论原生JDBC、dbutils、mybatis还是hibernate,使用log4j等日志框架可以看到生成的SQL,但是占位符和参数总是分开打印的。实在是不太友好。显示如下的效果:select*fromt_userwhereage>?
- Log4j日志脱敏记录一下
IAmZRH
JAVAjavalog4j
前言在项目上线环境中,需要记录程序运行时产生的各种错误信息、状态信息、调试信息、执行时间记录等日志信息。可以用于查找问题、定位数据等等操作。日志的具体实现可以有log4j和logback等,这里我们使用SLF4J作为日志系统的实现。使用SLF4J使用idea工具可以安装lombok插件,并引入maven包:org.projectlomboklombok1.18.4在需要打印日志的类上增加@Slf4
- log4j2 与 log4j使用时的几点小区别 - log4j2上手说明
CoderCodingNo
Java学习log4j单元测试
虽然log4j2目前还是beta版,不过OneCoder已经忍不住要尝试一下。跟使用log4j比起来,上手上主要的区别有。1、依赖的jar包。使用slf4j+log4j2时,依赖的jar包如下:(gradle配置,Maven对照修改即可)dependencies{compile("org.apache.logging.log4j:log4j-api:$log4j_version","org.apa
- log4j日志封装说明—slf4j对于log4j的日志封装-正确获取调用堆栈
CoderCodingNo
Java学习log4j
日志是项目中必用的东西,日志产品里最普及应该就是log4j了。(logback这里暂不讨论。)先看一下常用的log4j的用法,一般来说log4j都会配合slf4j或者common-logging使用,这里已slf4j为例。添加gradle依赖:dependencies{compile('log4j:log4j:1.2.17','org.slf4j:slf4j-api:1.7.5','org.slf
- Java开发常用类库
白与微光
Java开发常用类库参考https://cloud.tencent.com/developer/article/1522665https://segmentfault.com/a/1190000039359549一、日志相关类库Log4j/Log4j2:Apache的一个开源项目,高度可配置Logback:开源日志组件JUL:JDK自带日志库,也就是java.util.loggingJCL:Jak
- log4j 1.x 日志输出线程以唯一ID的形式配置
&loopy&
log4j单元测试
在Log4j1.x中,直接以线程ID(如Java中的Thread.currentThread().getId()返回的ID)的形式记录日志是可行的,但Log4j1.x本身并不直接提供一个内建的、自动将每个线程ID转换为“同一时间段内唯一ID”的机制。线程ID本身在JVM的上下文中就是唯一的(直到它被回收并重用,但这种情况在大多数应用中很罕见),但它不是跨JVM或跨系统唯一的。如果你的需求是确保即使
- Log4j 1.x如何升级到Log4j 2.x
&loopy&
log4j单元测试
Log4j1.x升级到Log4j2.x是一个涉及多个步骤的过程,主要包括删除旧版本、添加新版本依赖、配置新版本的配置文件等。以下是一个详细的升级步骤指南:一、准备阶段了解当前项目依赖:检查项目中所有使用Log4j1.x的地方,包括jar包和配置文件(如log4j.properties)。确定项目中是否还使用了与Log4j1.x相关的其他库,如slf4j-log4j12。备份当前配置:在进行任何更改
- log4j动态加载配置文件
MrMoving
log4jlog4jjavaapache
应用场景与问题当项目在运行时,我们如果需要修改log4j1.X或者log4j2的配置文件,一般来说我们是不能直接将项目停止运行再来修改文件重新部署的。于是就有这样一个问题:如何在不停止当前项目的运行的情况下,让系统能够自动地监控配置文件的修改状况,从而实现动态加载配置文件的功能?而log4j1.X和log4j2的差别略大,各自应该怎么实现这个功能?log4j1.X动态加载配置文件log4j1.X提
- SpringBoot Maven 升级自带jar包版本
呆呆a
jarmavenspringboot
当SpringBoot自带jar包版本较低时如图:想要升级log4j-to-slf4j到更高版本,需要在pom.xml文件中做修改:org.springframework.bootspring-boot-starterorg.apache.logging.log4jlog4j-to-slf4jorg.apache.logging.log4jlog4j-to-slf4j2.17.0org.apach
- JAVA XML转JSON工具类
张志飞
xmljson
packagecom.cm.util.xmlutl;importcom.alibaba.fastjson.JSONArray;importcom.alibaba.fastjson.JSONObject;importorg.apache.log4j.Logger;importorg.dom4j.*;importjava.io.File;importjava.io.FileInputStream;im
- SpringBoot+Kafka+ELK 完成海量日志收集(超详细)
2401_83703797
程序员springbootkafkaelk
SpringBoot项目准备引入log4j2替换SpringBoot默认log,demo项目结构如下:pomIndexController测试Controller,用以打印日志进行调试InputMDC用以获取log中的[%X{hostName}]、[%X{ip}]、[%X{applicationName}]三个字段值NetUtil启动项目,访问/index和/ero接口,可以看到项目中生成了app
- SparkStreaming业务逻辑处理的一些高级算子
看见我的小熊没
sparkStreamingscalasparkbigdatascala
1、reduceByKey reduceByKey是按key进行计算,操作的数据是每个批次内的数据(一个采集周期),不能跨批次计算。如果需要实现对历史数据的跨批次统计累加,则需要使用updateStateByKey算子或者mapWithState算子。packagecom.sparkscala.streamingimportorg.apache.log4j.{Level,Logger}impor
- IDEA创建SSM(Spring+SpringMVC+Mybatis)项目-Maven版
2401_85958214
intellij-ideaspringmybatis
数据库的密码password=admin定义初始连接数initialSize=1定义最大连接数maxActive=20定义最大空闲maxIdle=20定义最小空闲minIdle=1定义最长等待时间maxWait=600004.log4j.properties#日志输出级别log4j.rootLogger=debug,stdout,D,E#设置stdout的日志输出控制台log4j.appender
- Java日志详解
思静语
#日志java
文章目录概述日志级别日志框架LogBackLog4jSlf4j查看日志Log4j2和Logback都支持异步日志常见的日志管理系统日志收集分析概述日志的定义:程序执行过程中,记录程序运行的情况的信息日志的作用:Log日志,主要用于记录程序运行的情况,以便于程序在部署之后的排错调试等,也有利于将这些信息进行持久化(如果不将日志信息保存到文件或数据库,则信息便会丢失)。日志级别1、日志级别针对不同的场
- springboot整合shiro安全框架
heromps
Springboot安全apache
shiro快速开始1.导入依赖org.apache.shiroshiro-core1.8.0org.slf4jjcl-over-slf4j1.7.21org.slf4jslf4j-log4j121.7.21log4jlog4j1.2.17org.apache.shiroshiro-core1.8.02.配置文件shiro.ini[users]#user'root'withpassword'secr
- MyBatis框架搭建(利用Maven技术)
秋意钟
mybatismavenjava
一、pom.xml配置文件导入MyBatis框架包以及所需仓库(Maven技术在云端下载)4.0.0com.bdqnT369-MyBatiswar1.0-SNAPSHOTT369-MyBatisMavenWebapphttp://maven.apache.orgcom.mysqlmysql-connector-j8.2.0org.mybatismybatis3.5.16log4jlog4j1.2.
- 日志文件log4j
T_Y9943
工作记录log4jjunit
今天在处理一个文件,不打印日志的情况,刚好其他项目是logback,这个项目是log4j。另外这个项目中的logback.xml未生效。应该和pom文件有一点关系。不过懒得改了。能用就行。log4j的DailyRollingFileAppender,在当天不会显示出来。(困扰我许久)学习的详细配置如下:log4j配置详解
- MyBatis 环境搭建 2019-03-25
琴匣自鸣
MyBatis各版本下载地址点击Spring各版本下载地址点击Mybatis详解http://www.mybatis.org/mybatis-3/zh/configuration.html记录下犯过的错误1.驱动driver单词写错2.数据库驱动大小写不对3.url地址写错4.log4j需要配置文件没加初步搭建环境,准备工作:Mybatis.jarLog4j.jar数据库驱动jar注意Mybati
- 如何跟踪log4j漏洞原理及发现绕WAF的tips
H_00c8
image.pnglog4j漏洞的形成原因已经有很多分析文章了,这里说一说我是如何在了解到有漏洞后,跟进漏洞产生原理的,以及发现的一些绕WAFtips跟进漏洞产生原因的思路如何发现漏洞产生原因的了解到log4j并不支持,基于这一点,可以做个简单的实验在这里插入图片描述空格和尖括号同样报错,就不重复截图了。回到前面提到的2.15.0-rc1版本对JndiManager#lookup方法的修复情况,并
- JSP/JAVAWEB/SSM/J2EE高考志愿填报推荐系统的开发
计算机程序设计开发
javamysqljavawebssm推荐系统
目录1、概述2、功能描述3、数据表4、目录结构5、实现过程5.1SRC目录5.2webroot前端文件6、最终效果6.1前台用户效果6.2后台管理员用户效果1、概述开发环境:jdk1.8、tomcat7.0、mysql5.2开发工具:idea2019.3.1、navicat15编程语言后端:java;框架和引用的包:JavaBeanServletMVC、log4j.jar编程语言前端:JSP、ht
- 日志框架整理--logback
杨愁心
Java-log
logback是有log4j创始人设计的又一个开源日志框架logback当前分为三个模块:logbakc-core,logback-classic和logback-accesslogback-core:是其他两个模块的基础模块logback-classic:是log4j的一个改良版本。此外logback-classic完整实现SLF4JAPI,所以可以很方便的更换成其他日志系统,如log4j或JD
- java操作zookeeper
shuair
zookeeperzookeeper
java操作zookeeper文档linux安装java-centos安装java-linux配置java环境变量zookeeper单机安装zookeeper集群安装zookeeper客户端命令行操作、节点类型及监听器zookeeper集群写数据原理java操作zookeeper依赖信息junitjunittestorg.apache.logging.log4jlog4j-core2.8.2org
- How to do logging in C# with log4net
weixin_30216561
c#开发工具java
IfyouarewritingservercodeinC#ortoalesserextentdesktop/clientthenit'sagoodideatoincludeloggingcodesowhensomethinggoeswrongyouknowwheretostartlooking.TheJavaworldhasdonethesameforyearsandApachelog4jisav
- 深入理解Spring Boot日志框架与配置
一休哥助手
Springspringboot后端
目录SpringBoot日志框架概述SpringBoot默认日志框架:Logback日志配置文件日志级别的调整日志输出配置日志格式化日志轮转和归档集成其他日志框架日志管理工具最佳实践总结SpringBoot日志框架概述SpringBoot支持多种日志框架,如Logback、Log4j2和JavaUtilLogging(JUL)。其中,Logback是SpringBoot默认使用的日志框架。Spri
- 【Apache】漏洞
B1ackMa9ic
apache网络安全web安全网络攻击模型
文章目录Apache漏洞1.ApacheHTTPD多后缀解析漏洞2.ApacheSSI远程命令执行漏洞3.ApacheHTTP路径穿越漏洞4.ApacheHTTPSSRF漏洞5.Apachelog4j26.ApacheshiroApache漏洞1.ApacheHTTPD多后缀解析漏洞主要利用方式:文件类型欺骗:构造example.php.jpg的文件(只要一个文件含有.php后缀的文件即将被识别成
- PHP,安卓,UI,java,linux视频教程合集
cocos2d-x小菜
javaUIPHPandroidlinux
╔-----------------------------------╗┆
- 各表中的列名必须唯一。在表 'dbo.XXX' 中多次指定了列名 'XXX'。
bozch
.net.net mvc
在.net mvc5中,在执行某一操作的时候,出现了如下错误:
各表中的列名必须唯一。在表 'dbo.XXX' 中多次指定了列名 'XXX'。
经查询当前的操作与错误内容无关,经过对错误信息的排查发现,事故出现在数据库迁移上。
回想过去: 在迁移之前已经对数据库进行了添加字段操作,再次进行迁移插入XXX字段的时候,就会提示如上错误。
&
- Java 对象大小的计算
e200702084
java
Java对象的大小
如何计算一个对象的大小呢?
 
- Mybatis Spring
171815164
mybatis
ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
CustomerService userService = (CustomerService) ac.getBean("customerService");
Customer cust
- JVM 不稳定参数
g21121
jvm
-XX 参数被称为不稳定参数,之所以这么叫是因为此类参数的设置很容易引起JVM 性能上的差异,使JVM 存在极大的不稳定性。当然这是在非合理设置的前提下,如果此类参数设置合理讲大大提高JVM 的性能及稳定性。 可以说“不稳定参数”
- 用户自动登录网站
永夜-极光
用户
1.目标:实现用户登录后,再次登录就自动登录,无需用户名和密码
2.思路:将用户的信息保存为cookie
每次用户访问网站,通过filter拦截所有请求,在filter中读取所有的cookie,如果找到了保存登录信息的cookie,那么在cookie中读取登录信息,然后直接
- centos7 安装后失去win7的引导记录
程序员是怎么炼成的
操作系统
1.使用root身份(必须)打开 /boot/grub2/grub.cfg 2.找到 ### BEGIN /etc/grub.d/30_os-prober ### 在后面添加 menuentry "Windows 7 (loader) (on /dev/sda1)" { 
- Oracle 10g 官方中文安装帮助文档以及Oracle官方中文教程文档下载
aijuans
oracle
Oracle 10g 官方中文安装帮助文档下载:http://download.csdn.net/tag/Oracle%E4%B8%AD%E6%96%87API%EF%BC%8COracle%E4%B8%AD%E6%96%87%E6%96%87%E6%A1%A3%EF%BC%8Coracle%E5%AD%A6%E4%B9%A0%E6%96%87%E6%A1%A3 Oracle 10g 官方中文教程
- JavaEE开源快速开发平台G4Studio_V3.2发布了
無為子
AOPoraclemysqljavaeeG4Studio
我非常高兴地宣布,今天我们最新的JavaEE开源快速开发平台G4Studio_V3.2版本已经正式发布。大家可以通过如下地址下载。
访问G4Studio网站
http://www.g4it.org
G4Studio_V3.2版本变更日志
功能新增
(1).新增了系统右下角滑出提示窗口功能。
(2).新增了文件资源的Zip压缩和解压缩
- Oracle常用的单行函数应用技巧总结
百合不是茶
日期函数转换函数(核心)数字函数通用函数(核心)字符函数
单行函数; 字符函数,数字函数,日期函数,转换函数(核心),通用函数(核心)
一:字符函数:
.UPPER(字符串) 将字符串转为大写
.LOWER (字符串) 将字符串转为小写
.INITCAP(字符串) 将首字母大写
.LENGTH (字符串) 字符串的长度
.REPLACE(字符串,'A','_') 将字符串字符A转换成_
- Mockito异常测试实例
bijian1013
java单元测试mockito
Mockito异常测试实例:
package com.bijian.study;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.
- GA与量子恒道统计
Bill_chen
JavaScript浏览器百度Google防火墙
前一阵子,统计**网址时,Google Analytics(GA) 和量子恒道统计(也称量子统计),数据有较大的偏差,仔细找相关资料研究了下,总结如下:
为何GA和量子网站统计(量子统计前身为雅虎统计)结果不同?
首先:没有一种网站统计工具能保证百分之百的准确出现该问题可能有以下几个原因:(1)不同的统计分析系统的算法机制不同;(2)统计代码放置的位置和前后
- 【Linux命令三】Top命令
bit1129
linux命令
Linux的Top命令类似于Windows的任务管理器,可以查看当前系统的运行情况,包括CPU、内存的使用情况等。如下是一个Top命令的执行结果:
top - 21:22:04 up 1 day, 23:49, 1 user, load average: 1.10, 1.66, 1.99
Tasks: 202 total, 4 running, 198 sl
- spring四种依赖注入方式
白糖_
spring
平常的java开发中,程序员在某个类中需要依赖其它类的方法,则通常是new一个依赖类再调用类实例的方法,这种开发存在的问题是new的类实例不好统一管理,spring提出了依赖注入的思想,即依赖类不由程序员实例化,而是通过spring容器帮我们new指定实例并且将实例注入到需要该对象的类中。依赖注入的另一种说法是“控制反转”,通俗的理解是:平常我们new一个实例,这个实例的控制权是我
- angular.injector
boyitech
AngularJSAngularJS API
angular.injector
描述: 创建一个injector对象, 调用injector对象的方法可以获得angular的service, 或者用来做依赖注入. 使用方法: angular.injector(modules, [strictDi]) 参数详解: Param Type Details mod
- java-同步访问一个数组Integer[10],生产者不断地往数组放入整数1000,数组满时等待;消费者不断地将数组里面的数置零,数组空时等待
bylijinnan
Integer
public class PC {
/**
* 题目:生产者-消费者。
* 同步访问一个数组Integer[10],生产者不断地往数组放入整数1000,数组满时等待;消费者不断地将数组里面的数置零,数组空时等待。
*/
private static final Integer[] val=new Integer[10];
private static
- 使用Struts2.2.1配置
Chen.H
apachespringWebxmlstruts
Struts2.2.1 需要如下 jar包: commons-fileupload-1.2.1.jar commons-io-1.3.2.jar commons-logging-1.0.4.jar freemarker-2.3.16.jar javassist-3.7.ga.jar ognl-3.0.jar spring.jar
struts2-core-2.2.1.jar struts2-sp
- [职业与教育]青春之歌
comsci
教育
每个人都有自己的青春之歌............但是我要说的却不是青春...
大家如果在自己的职业生涯没有给自己以后创业留一点点机会,仅仅凭学历和人脉关系,是难以在竞争激烈的市场中生存下去的....
&nbs
- oracle连接(join)中使用using关键字
daizj
JOINoraclesqlusing
在oracle连接(join)中使用using关键字
34. View the Exhibit and examine the structure of the ORDERS and ORDER_ITEMS tables.
Evaluate the following SQL statement:
SELECT oi.order_id, product_id, order_date
FRO
- NIO示例
daysinsun
nio
NIO服务端代码:
public class NIOServer {
private Selector selector;
public void startServer(int port) throws IOException {
ServerSocketChannel serverChannel = ServerSocketChannel.open(
- C语言学习homework1
dcj3sjt126com
chomework
0、 课堂练习做完
1、使用sizeof计算出你所知道的所有的类型占用的空间。
int x;
sizeof(x);
sizeof(int);
# include <stdio.h>
int main(void)
{
int x1;
char x2;
double x3;
float x4;
printf(&quo
- select in order by , mysql排序
dcj3sjt126com
mysql
If i select like this:
SELECT id FROM users WHERE id IN(3,4,8,1);
This by default will select users in this order
1,3,4,8,
I would like to select them in the same order that i put IN() values so:
- 页面校验-新建项目
fanxiaolong
页面校验
$(document).ready(
function() {
var flag = true;
$('#changeform').submit(function() {
var projectScValNull = true;
var s ="";
var parent_id = $("#parent_id").v
- Ehcache(02)——ehcache.xml简介
234390216
ehcacheehcache.xml简介
ehcache.xml简介
ehcache.xml文件是用来定义Ehcache的配置信息的,更准确的来说它是定义CacheManager的配置信息的。根据之前我们在《Ehcache简介》一文中对CacheManager的介绍我们知道一切Ehcache的应用都是从CacheManager开始的。在不指定配置信
- junit 4.11中三个新功能
jackyrong
java
junit 4.11中两个新增的功能,首先是注解中可以参数化,比如
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runn
- 国外程序员爱用苹果Mac电脑的10大理由
php教程分享
windowsPHPunixMicrosoftperl
Mac 在国外很受欢迎,尤其是在 设计/web开发/IT 人员圈子里。普通用户喜欢 Mac 可以理解,毕竟 Mac 设计美观,简单好用,没有病毒。那么为什么专业人士也对 Mac 情有独钟呢?从个人使用经验来看我想有下面几个原因:
1、Mac OS X 是基于 Unix 的
这一点太重要了,尤其是对开发人员,至少对于我来说很重要,这意味着Unix 下一堆好用的工具都可以随手捡到。如果你是个 wi
- 位运算、异或的实际应用
wenjinglian
位运算
一. 位操作基础,用一张表描述位操作符的应用规则并详细解释。
二. 常用位操作小技巧,有判断奇偶、交换两数、变换符号、求绝对值。
三. 位操作与空间压缩,针对筛素数进行空间压缩。
&n
- weblogic部署项目出现的一些问题(持续补充中……)
Everyday都不同
weblogic部署失败
好吧,weblogic的问题确实……
问题一:
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [zip:E:/weblogic/user_projects/domains/base_domain/serve
- tomcat7性能调优(01)
toknowme
tomcat7
Tomcat优化: 1、最大连接数最大线程等设置
<Connector port="8082" protocol="HTTP/1.1"
useBodyEncodingForURI="t
- PO VO DAO DTO BO TO概念与区别
xp9802
javaDAO设计模式bean领域模型
O/R Mapping 是 Object Relational Mapping(对象关系映射)的缩写。通俗点讲,就是将对象与关系数据库绑定,用对象来表示关系数据。在O/R Mapping的世界里,有两个基本的也是重要的东东需要了解,即VO,PO。
它们的关系应该是相互独立的,一个VO可以只是PO的部分,也可以是多个PO构成,同样也可以等同于一个PO(指的是他们的属性)。这样,PO独立出来,数据持
It needs to be followed with a =true otherwise you get errors that it doesn't know how to debug...
Thursday, August 24, 2006 12:21:00 AMNo, you need not specify =true. Just providing -Dlog4j.debug while launching your java program works. Here's an example:
Thursday, August 24, 2006 6:25:00 PMjava -Dlog4j.debug org.myapp.SampleProg
You will see the log4j output something similar to:
log4j: Trying to find [log4j.xml] using context classloader sun.misc.Launcher$AppClassLoader@e80a59.
log4j: Using URL [file:/E:/Samples/log4j.xml] for automatic log4j configuration.
log4j: Preferred configurator class: org.apache.log4j.xml.DOMConfigurator
log4j: System property is :null
log4j: Standard DocumentBuilderFactory search succeded.
log4j: DocumentBuilderFactory is: org.apache.crimson.jaxp.DocumentBuilderFactoryImpl
log4j: debug attribute= "false".
I added -Dlog4j.debug, but the output is not as descriptive as what you posted. All I get is the following:
Friday, February 22, 2008 6:24:00 AMlog4j: Trying to find [log4j.properties] using context classloader org.eclipse.core.runtime.internal.adaptor.ContextFinder@ede48.
log4j: Trying to find [log4j.properties] using org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@57f993 class loader.
log4j: Trying to find [log4j.properties] using ClassLoader.getSystemResource().
log4j: Could not find resource: [log4j.properties].
I also tried adding the directory of interest to my classpath, and simply putting the file in a major directory, but log4j just can't see it.
Any ideas?
I am the same person as the above comment...
Friday, February 22, 2008 6:53:00 AMI added the PropertyConfigurator.configure($PATH_TO_FILE) command, and it worked. But I would prefer use the previous method where it gets the file from the classpath. If you have any tips on how to get that to work, I would appreciate it.
I am using eclipse, and I checked that the file is in the classpath there.
Thanks in advance.
I added -Dlog4j.debug, but the output is not as descriptive as what you posted. All I get is the following:
Friday, February 22, 2008 2:40:00 PM...
log4j: Could not find resource: [log4j.properties].
The last line shows that the log4.properties is not found in the classpath. You mention that you are using Eclipse. I guess you have not placed the log4j.properties (or log4j.xml) at the right place in the project. If you have project created in D:\MySampleApp folder, then place the log4j.properties (or log4j.xml) at the root of the project (i.e. directly in D:\MySampleApp folder).
If you have project created in D:\MySampleApp folder, then place the log4j.properties (or log4j.xml) at the root of the project (i.e. directly in D:\MySampleApp folder).
Friday, February 22, 2008 10:51:00 PMThanks for the tip. I tried placing it in various locations within the project (at the root, in the root of the build.eclipse directory, etc.) but to no avail. I wish that the debug output would tell me where it is looking, as it did in your output. I have searched but found no way of making it more verbose.
Thursday, April 10, 2008 10:16:00 PMMark T. W. Ebbert said...
If you have project created in D:\MySampleApp folder, then place the log4j.properties (or log4j.xml) at the root of the project (i.e. directly in D:\MySampleApp folder).
Thanks for the tip. I tried placing it in various locations within the project (at the root, in the root of the build.eclipse directory, etc.) but to no avail. I wish that the debug output would tell me where it is looking, as it did in your output. I have searched but found no way of making it more verbose.
Mark, if you use Eclipse go to project properties, then Java Build Path. There you'll find currently defined classpath for your project.
For example my project defines 2 source folders on build path:
{project name}/src/main/java and {project name}/src/main/resources. I added the log4j.properties file under {project name}/src/main/resources/config/log4j.properties. Whan I ran the project I had to pass the parameter as -Dlog4j.configuration=config/log4j.propertiesand it configured log4j properly.
Hope this helps!
I had a problem with log4j too, my error was:
Wednesday, June 25, 2008 6:08:00 PMlog4j:WARN No appenders could be found for logger ...
log4j:WARN Please initialize the log4j system properly.
To solve this problem I used :
BasicConfigurator.configure(); line on start main method.
import org.apache.log4j.BasicConfigurator;
It solved my problem. Maybe it help you too.
otmek
thanks mate, you saved me some time with this...
Tuesday, August 05, 2008 12:22:00 AMhi Anonymous, BasicConfigurator.configure() helped me too. thanks.
Thursday, December 11, 2008 10:45:00 PMBasicConfigurator.configure() did it for me too... I put it in the initialization phase of my application listener (using JSF)
Monday, January 12, 2009 10:23:00 PMThanks!
Thank sir, this simple command saved me a ton of time at work.
Saturday, January 31, 2009 3:38:00 AMthanks.
Tuesday, March 17, 2009 2:04:00 PMGuys,
Friday, September 04, 2009 8:20:00 PMIf you use BasicConfigurator it will work, however, you will have only console appender with log level hard set and an useless log4j.config file.
To solve it, just put log4j.config file inside src folder.
I know it may not seem to be a very clean solution, but then, you'll have time figure out how you can set your classpath to allow log4j.properties to be read from project root folder.
Best regards
You are right,
Monday, September 07, 2009 5:45:00 PMIts for console default logger.
but if we need to use log4j.properties file's custom logging then its no use.
As Roberto mentioned, put a log4j.properties file in src older but still having same waring,
log4j:WARN No appenders could be found for logger (src.com.test.Calculator).
log4j:WARN Please initialize the log4j system properly.
please help on this..
Deepa,
Monday, September 07, 2009 5:48:00 PMYou mention that you placed the log4j.properties in the src folder. However, if you are still seeing that WARN message then i guess log4j did not find the log4j.properties.
As explained in the article, try using the -Dlog4j.debug option to see whether log4j is able to find the configuration file.
hi Jaikiran,
Wednesday, September 09, 2009 11:31:00 AMI understood the problem why log4j did not find the log4j.properties even though placing it in src folder..,
Not just for compilation it needs for running application as well (the thing which was missing :( ), so i put one copy of this properties file where the classes exit of my src.
src
--com
-- test
-- Hello.java
log4j.properties
classes
--com
-- test
-- Hello.class
log4j.properties
it works .. Thanks :)
Deepa.....
Dude that BasicConfiguration helped me a lot...Thanks very much!!!!!
Saturday, October 03, 2009 2:10:00 AMHey thanks for sharing about looking at the java build path to know where to put the log4j.properties.
Tuesday, January 05, 2010 3:26:00 PMFinally solve my problem when dealing with a package.
I guess, it will solve this problem if you fully qualify the class...
Friday, July 16, 2010 12:23:00 AMfor example,
private static Logger log = Logger.getLogger("com.fmr.fims.deconv.XrefCnvThread.class");
instead of just private static Logger log = Logger.getLogger("XrefCnvThread.class");
hi Anonymous, BasicConfigurator.configure() helped me too. thanks.
Wednesday, August 04, 2010 9:04:00 AMThank you soo much this command spared my precious hours :)
Thursday, August 12, 2010 5:50:00 PMThanks a ton for sharing this information. It helped a lot.
Thursday, January 06, 2011 11:45:00 AMI just had a nightmare time debugging a problem similar to what you guys describe.
Friday, April 01, 2011 1:06:00 PMFor me, the solution was to use the full "file:/" URL form. For example:
-Dlog4j.configuration=file:/jamesGosling/log4j.xml
This is briefly discussed (but totally inadequately emphasized) in the log4j manual:
http://logging.apache.org/log4j/1.2/manual.html
(See "Example 4" under the "Default Initialization under Tomcat" section)
Mark T. W. Ebbert, You save me! ;) thanks a lot!
Saturday, April 23, 2011 10:08:00 PM"The last line shows that the log4.properties is not found in the classpath. You mention that you are using Eclipse. I guess you have not placed the log4j.properties (or log4j.xml) at the right place in the project. If you have project created in D:\MySampleApp folder, then place the log4j.properties (or log4j.xml) at the root of the project (i.e. directly in D:\MySampleApp"
Tuesday, May 03, 2011 7:44:00 AMIt works...
I work in linux environment with eclipse.
Monday, August 22, 2011 1:13:00 PMI placed log4j.properties file in /src folder and it worked.
Thanks for the help.
WOW thank you Anonymous from Friday, April 01, 2011 1:06:00 PM
Wednesday, October 12, 2011 11:15:00 PMI had put the properties file in the classpath, and I had tried specifying the properties file via the command line parameter -Dlog4j.configuration, but neither seemed to be working. Finally, I tried specifying the file path as a URI rather than a local file path, and it finally worked.
Try this:
-Dlog4j.configuration=file:C:\MyPath\log4j.properties
instead of this:
-Dlog4j.configuration=C:\MyPath\log4j.properties
BasicConfigurator.configure();
Wednesday, January 18, 2012 11:24:00 PMsolved my problem. Thanks for your help.
Thanks Anonymous/otmek,
Friday, March 09, 2012 10:44:00 PMBasicConfigurator solved my problem.
Vidhya
BasicConfigurator.configure() helped me!
Saturday, March 17, 2012 2:29:00 AMThanks! :)
Thanks a lot, using
Wednesday, April 11, 2012 3:36:00 PMBasicConfigurator.configure();
worked fine (for console output)!!!