log4j

Log SQL queries in project using MyBatis and Spring

拜拜、爱过 提交于 2019-12-03 08:33:31
In my project i have <bean id="ABCSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="ABCDataSource" /> <property name="mapperLocations"> <list> <value>classpath:com/myco/dao/XYZMapper.xml</value> </list> </property> <bean> and log4j.logger.java.sql.Connection=debug, stdout, abclog log4j.logger.java.sql.PreparedStatement=debug, stdout, abclog log4j.logger.java.sql=debug, stdout, abclog log4j.logger.org.mybatis=debug, stdout, abclog log4j.logger.org.apache.ibatis=debug, stdout, abclog I dont see the SQL queries when i run the applicartion in log

How to set the log level to DEBUG during Junit tests?

只愿长相守 提交于 2019-12-03 08:31:54
问题 I am using SLF4J with LOG4J, and the configurations are usually in the log4j.properties , and it sets the log level to INFO. However during the tests I would like to set the logs to DEBUG. I can't see a way to automate this, neither to have something like log4j.tests.properties that would be loaded only during tests. So I've tried doing this programmatically in the test setup (the @BeforeClass): LogManager.getRootLogger().setLevel(Level.ALL); With no success... I am using these versions:

Log4J attach only one class to an appender

匿名 (未验证) 提交于 2019-12-03 08:28:06
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I need to poll the JVM memory stats of my running application on a regular basis. I'm running a service that does this and writes the stats to the root Logger (I don't have much control over Root Logger usage or not). What I want to do is route just these logging messages to a single appender. This appender should only process logging messages from this one class, and not from any other class. The other appenders shouldn't receive the messages from this one class. So far I have the log messages only going to this 'memoryStats'

Maven Plugin Logger Compatibility

假装没事ソ 提交于 2019-12-03 08:18:56
I am writing a Maven plugin (Mojo) that imports a Jar library used by other projects. At least one of the classes in that library use Apache Log4j for logging, but Log4j is not going to be properly configured by the logger that Maven provides to the Mojo. Is there any simple way to bridge between these? Unfortunately, org.apache.log4j.Logger and org.apache.maven.logging.Log do not share a common superinterface or superclass, so I can't simply have a setLog() type function. Any suggestions would be welcome; currently I am planning to either just ignore it, or write a bridge class that can use

关于一个tomcat里面放2个项目启动报listener错误

﹥>﹥吖頭↗ 提交于 2019-12-03 08:17:18
今天在测试环境发布项目的时候,遇到个奇怪的问题。问题大致情况是: 我将2个不同的项目同时部署到了同一个tomcat,然后启动,发现报listener错误。如图: 我以为是我的项目问题。于是开始采用排除法来排查问题。首先我先删除掉一个项目,单个部署,发现两个项目单独部署的时候都没有问题。唯独一起部署的时候,才会出现这个错误。最终,我猜测怀疑是log4j的问题。于是我把log4j的打印日志配置给注释了。结果神奇的事情发生了,启动成功了。最终我看了两个项目的log4j代码配置,发现都采用了spring的Listener监听。 后来,我将项目1采用了监听,项目2采用了Servlet的配置加载。 如图: 具体怎么弄可以看我的博客: http://my.oschina.net/kkrgwbj/blog/638780 这样就可以成功启动了。 来源: oschina 链接: https://my.oschina.net/u/1471190/blog/669325

shiro入门

你说的曾经没有我的故事 提交于 2019-12-03 07:52:10
Shiro 简介 1. 什么是 shiro shiro 是 apache 的一个开源框架,是一个权限管理的框架,实现 用户认证、用户授权。 spring 中有 spring security ( 原名 Acegi) ,是一个权限框架,它和 spring 依赖过于紧密,没有 shiro 使用简单。 shiro 不依赖于 spring , shiro 不仅可以实现 web 应用的权限管理,还可以实现 c/s 系统, 分布式系统权限管理, shiro 属于轻量框架,越来越多企业项目开始使用 shiro 。 2. 在应用程序角度来观察如何使用 Shiro 完成工作 Subject :主体,代表了当前“用户”,这个用户不一定是一个具体的人,与当前应用交互的任何东西都是 Subject ,如网络爬虫,机器人等;即一个抽象概念;所有 Subject 都绑定到 SecurityManager ,与 Subject 的所有交互都会委托给 SecurityManager ;可以把 Subject 认为是一个门面; SecurityManager 才是实际的执行者; SecurityManager :安全管理器;即所有与安全有关的操作都会与 SecurityManager 交互;且它管理着所有 Subject ;可以看出它是 Shiro 的核心,它负责与后边介绍的其他组件进行交互,如果学习过

log4j:ERROR Failed to rename

你说的曾经没有我的故事 提交于 2019-12-03 07:50:43
I get this error "log4j:ERROR Failed to rename" in my tomcat server log. I have multiple DailyRollingFileAppender in my log4j XML. And each appender points to different file. Only once instance of the application is running. I used Handle utility and run the command (with log file name as parameter) handle -f ams-app.log and the result is Tomcat7.exe pid: 5032 type: File 54C: E:\apps\ams\logs\ams-app.log From this I assume there is only one lock on the file. My environment Windows Server 2008, tomcat 7.0 and Java 6 and slf4j-log4j12(1.5.6) This problem was not happening when same application

Using different Log files for every thread created

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am working on logging with log4j, i have sample code which creats certain number of threads , i want to use different log files for each threads. so I have use the PropertyConfigurator.configure() which takes a property object. I have configured the property object in my code i.e hardcoded , but I want to load it external to code. Now I want to provide all the configurations externally through a property file i.e not to hardcode them in code and at runtime add the two properties - props.setProperty("log4j.logger."+"Thread" + Thread

How to Re-Execute Log4j “Default Initialization Procedure”?

南笙酒味 提交于 2019-12-03 07:48:42
问题 At runtime I often create/modify log4j Loggers, Appenders, Levels, Layouts, and time to time need to reset everything back to defaults. Log4j system has well defined Default Initialization Procedure that is executed when log4j classes are loaded into memory. Is there any way to re-execute the entire Procedure programmatically later at runtime? I found several resetConfiguration() methods in log4j documentation, but not sure if any of them will do what the Default Initialization Procedure does

Log4j FileAppender recreating deleted files

匿名 (未验证) 提交于 2019-12-03 07:36:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using Log4j as logging framework in a project I am working on. I have the following situation: Log4j is configured to write the logs into a log file. At some point, this log file is copied to another destination and deleted. Logging framework keeps working, but the logs are not written to the log file because it is deleted. Is there any way to tell Log4j to recreate the file and keep writing the logs into the log file. Best regards, Rashid 回答1: I study the source of log4j and find log4j can't create new log file, it just print the error