log4j

Log4j.properties模板

青春壹個敷衍的年華 提交于 2019-12-04 13:54:39
log4j.rootLogger=INFO,CONSOLE log4j.addivity.org.apache=true # console log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender log4j.appender.CONSOLE.Threshold=INFO log4j.appender.CONSOLE.Target=System.out log4j.appender.CONSOLE.Encoding=UTF-8 log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout log4j.appender.CONSOLE.layout.ConversionPattern=[demo] %-5p %d{yyyy-MM-dd HH\:mm\:ss} - %C.%M(%L)[%t] - %m%n # all log4j.logger.com.demo=INFO, DEMO log4j.appender.DEMO=org.apache.log4j.RollingFileAppender log4j.appender.DEMO.File=${catalina.base}/logs/demo.log log4j.appender.DEMO.MaxFileSize

log4j2 配置文件解读

瘦欲@ 提交于 2019-12-04 13:50:27
1、日志相关介绍   日志接口(slf4j):slf4j是对所有日志框架制定的一种规范、标准、接口,并不是一个框架的具体的实现,因为接口并不能独立使用,需要和具体的日志框架实现配合使用(如log4j、logback)。常用的日志实现方式有log4j、logback、log4j2,log4j是apache实现的一个开源日志组件;logback同样是由log4j的作者设计完成的,拥有更好的特性,用来取代log4j的一个日志框架,是slf4j的原生实现;log4j2是log4j 1.x和logback的改进版,据说采用了一些新技术(无锁异步、等等),使得日志的吞吐量、性能比log4j 1.x提高很多,并解决了一些死锁的bug,而且配置更加简单灵活。以下以log4j2 xml配置文件为例。 2、log4j2.xml文件内容如下 <?xml version="1.0" encoding="utf-8"?> <!-- log4j2内部日志配置,status表示日志级别,monitorInterval表示监控间隔 --> <Configuration status="WARN" monitorInterval="10"> <!-- 属性配置,后续可以使用${xxx}获取对应的值 --> <properties> <!-- 日志存放根目录 --> <property name="LOG_HOME"

Have you seen an appender that would log to separate files based on NDC in Log4j? [closed]

巧了我就是萌 提交于 2019-12-04 13:48:41
We have only a very small number of customers (fewer than 50) and we would like each one to have its own separate log file into which all of its server side logging info goes. I know you could use NDC and filters to direct log statements to different files using the standard appenders in Log4j but that would require quite a bit more setup (to create loggers for all existing customers) and it wouldn't automatically accomodate the addition of a new customer into the system. Have you ever seen an appender which would split out log statements to separate files based on the Log4j NDC value? I

Log SQL queries in project using MyBatis and Spring

泄露秘密 提交于 2019-12-04 13:28:09
问题 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

springboot2.0 : log4j 的基础使用

半世苍凉 提交于 2019-12-04 13:24:32
springboot2.x 配置log4j 传统方式打印日志比较复杂, 每次打印需要定义全局变量 private static final Logger logger = LoggerFactory.getLogger(this.getClass()) springboot2.x ,只需要加个注解~~~~ 项目结构 影响文件: pom.xml , application.yml , logback.xml pom.xml 引入jar包 <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.16.10</version> </dependency> application.yml 配置 logging: level: root: ERROR org.springframework: ERROR org.mybatis: ERROR #自己的工程包名录 : 日志级别 org.xxx.xxx.wx: DEBUG org.xxx.xxx.db: DEBUG org.xx.xx: INFO file: /var/logs/litemall-wx-api/xxx.log logback.xml <?xml version="1.0" encoding="UTF-8

Grails and Log4J : How to logs in different files with same level?

一笑奈何 提交于 2019-12-04 13:03:44
I would like configure Grails log4j to store logs in different files depending of the controller. So, I have a package.Controller1 and package.Controller2 . On controller1, I would like store in logfile1.logs and on controller2 on logfile2.logs in debug mode. How to do that ? Thanks. Burt Beckwith Create the appenders as file (or rollingFile etc.): appenders { file name: "logfile1", file: "/path/to/logfile1.logs" file name: "logfile2", file: "/path/to/logfile2.logs" } and then use the Map syntax to partition the two controllers into separate appenders: debug logfile1: "grails.app.controller

Maven Plugin Logger Compatibility

陌路散爱 提交于 2019-12-04 12:59:39
问题 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

Scala: Write log to file with log4j

♀尐吖头ヾ 提交于 2019-12-04 12:47:02
问题 I am trying to build a scala based jar file in eclipse that uses log4j to make logs. It prints out perfectly in the console but when I try to use log4j.properties file to make it write to a log file, nothing happens. The project structure is as follows loggerTest.scala package scala.n*****.n**** import org.apache.log4j.Logger object loggerTest extends LogHelper { def main(args : Array[String]){ log.info("This is info"); log.error("This is error"); log.warn("This is warn"); } } trait LogHelper

log4j:ERROR Failed to rename

人走茶凉 提交于 2019-12-04 12:20:00
问题 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

How to set log4j.properties in Eclipse?

心不动则不痛 提交于 2019-12-04 12:17:58
问题 I'm trying to run this example, but I have some problems with configuration. I copied log4j-jms.properties , jndi.properties , Log4jJMSAppenderExample.java ProjectJMS | \_ src | \_ Log4jJMSAppenderExample.java | \_ jndi.propeties \_ log4j-jms.properties and run activemq in my console. When I ran my example I got log4j:WARN No appenders could be found for logger (org.apache.activemq.transport.WireFormatNegotiator). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http:/