Spring如何加载log4j配置文件

今天有朋友在群里问了这个问题,于是写了这篇文章进行整理。
问题如下:
在项目中添加了log4j.properties配置文件,并没有在Spring配置文件中配置,也没有在web.xml中配置,但是代码中却可以正常使用log4j的功能,那么Spring是如何加载并使用这个log4j配置文件的呢?
答案整理如下:
- Spring默认加载的是classpath根目录下面的log4j.properties,这也是为何在项目中添加了log4j.properties配置文件就可以正常使用log4j的功能了。
- 如果配置文件名称不是这个,或者说文件目录不是这个,则需要在web.xml中对
log4jConfigLocation属性进行配置。
具体可以参考如下几篇博客:
Spring如何加载log4j配置文件的更多相关文章
- Spring中加载xml配置文件的六种方式
Spring中加载xml配置文件的六种方式 博客分类: Spring&EJB XMLSpringWebBeanBlog 因为目前正在从事一个项目,项目中一个需求就是所有的功能都是插件的形式装 ...
- spring动态加载(刷新)配置文件 [复制链接]
待验证 在程序开发时,通常会经常修改spring的配置文件,不得不重启tomcat来加载spring配,费时费力.如果能在不重启tomcat的情况下,手动动态加载spring 配置文件,动态重启读取s ...
- spring BeanFactory加载xml配置文件示例
项目目录结构如下: HelloWorld.java package com.thief.demo; public class HelloWorld { public void sayHello() { ...
- 利用【监听器】动态加载Log4j配置文件
转自:https://veromca273.iteye.com/blog/1889304 1 创建监听器: public class LogListener implements ServletCon ...
- spring boot 加载application配置文件
这就要注意了
- Spring中加载xml配置文件的常用的几种方式
https://blog.csdn.net/qq877507054/article/details/62432062
- WEB系统启动时加载Log4j的配置文件
如何在系统启动的时候加载log4j的配置文件呢? 1.自定义监听类并且继承“ServletContextListener”接口: package cn.ibeans.common; import ja ...
- Spring中加载配置文件的方式
原文:http://blog.csdn.net/snowjlz/article/details/8158560 Spring 中加载XML配置文件的方式,好像有3种, XML是最常见的Spring 应 ...
- 脚本命令加载外部配置文件夹conf
加载log4j配置文件 Log4iConfigurer类 public class Log4iConfigurer { private static boolean INITIALIZED = fal ...
随机推荐
- event.target和event.currentTarget区别
首先本质区别是: event.target返回触发事件的元素 event.currentTarget返回绑定事件的元素
- python ddt
#!/usr/bin/env/python # -*- coding: utf-8 -*- # @Time : 2018/12/15 15:27 # @Author : ChenAdong # @Em ...
- AlexNet卷积神经网络【前向反馈】
1.代码实现 # -*- coding: utf-8 -*- """ Created on Wed Nov 14 17:13:05 2018 @author: zhen ...
- Python平时代码的一些知识
os.walk的作用: def file_name(file_dir): for root, dirs, files in os.walk(file_dir): print(root) #当前目录 ...
- 通过http上下文判断是否是Ajax请求
using System; namespace System.Web.Mvc { /// <summary>Represents a class that extends the < ...
- MySQL Host is blocked because of many connection errors 解决方法
应用日志提示错误:create connection error, url: jdbc:mysql://10.45.236.235:3306/db_wang?useUnicode=true&c ...
- Nginx 的 TCP 负载均衡介绍
Nginx除了以前常用的HTTP负载均衡外,Nginx增加基于TCP协议实现的负载均衡方法. HTTP负载均衡,也就是我们通常所有“七层负载均衡”,工作在第七层“应用层”.而TCP负载均衡,就是我们通 ...
- Scrapy 框架 增量式
增量式: 用来检测网站中数据的更新情况 from scrapy.linkextractors import LinkExtractor from scrapy.spiders import Crawl ...
- VGG网络
VGG论文给出了一个非常振奋人心的结论:卷积神经网络的深度增加和小卷积核的使用对网络的最终分类识别效果有很大的作用.记得在AlexNet论文中,也做了最后指出了网络深度的对最终的分类结果有很大的作用. ...
- SQlite源码分析--源网站
http://huili.github.io/B-treeImplementation/hierarchicalorganization.html SQLite中的B-tree SQLite中每个数据 ...