
Tag archives for Log4j
Hello,
CLIENT SIDE
Everybody has already been confronted with problem of localization of log4j.properties or dfc.properties files used on runtime. The DFC configuration files like log4j.properties and dfc.properties are located through the classpath found in WAR files and EAR files. More, for information, there are several possibilities to point to dfc.properties file:
Include Statement
A dfc.properties can contain an include statement pointing at the ...more»
Hi,
After my previous posts concerning Java: Log4j Concepts and Explanations and Java: Log4j in practice, I would expose a solution to overwrite the file path on runtime.
Libraries needed : commons-lang3-3.1.jar, commons-logging-1.1.1.jar and log4j-1.2.15.jar.
MainApp.java
Config.properties
BUSINESS_LOG_FILE=D\:\\...\\... \\data\\results\\InjectorBusiness.log
TECHNICAL_LOG_FILE=D\:\\...\\...\\data\\results\\InjectorTechnical.log
LogUtil.java
log4jInjector.properties
log4j.rootCategory=ALL,CONSOLE,TECHNICALLOGFILE
log4j.logger.com.ho.log4j.test2.LogUtil=INFO,BUSINESSLOGFILE
#------------------- CONSOLE --------------------------
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern= %m%n
log4j.appender.CONSOLE.Threshold=INFO
#------------------- FILE --------------------------
log4j.appender.TECHNICALLOGFILE=org.apache.log4j.RollingFileAppender
log4j.appender.TECHNICALLOGFILE.File=injectortech.log
log4j.appender.TECHNICALLOGFILE.MaxFileSize=30MB
log4j.appender.TECHNICALLOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.TECHNICALLOGFILE.layout.ConversionPattern=%d{ABSOLUTE} %5p %c - %m%n
log4j.appender.TECHNICALLOGFILE.Threshold=ALL
#------------------- BUSINESSLOGFILE --------------------------
log4j.appender.BUSINESSLOGFILE=org.apache.log4j.DailyRollingFileAppender
#log4j.appender.BUSINESSLOGFILE.File=${catalina.base}/logs/Injector.log
log4j.appender.BUSINESSLOGFILE.File=injector.log
log4j.appender.BUSINESSLOGFILE.DatePattern='.'yyy-MM-dd-HH
log4j.appender.BUSINESSLOGFILE.MaxFileSize=30MB
log4j.appender.BUSINESSLOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.BUSINESSLOGFILE.Threshold=ALL
log4j.appender.BUSINESSLOGFILE.Append=true
log4j.appender.BUSINESSLOGFILE.layout.ConversionPattern=%-d{MMM dd HH:mm:ss} %-5p %c %M %m%n
Execute the MainApp class with the following program ...more»
Hi,
After my post Java: Log4j Concepts and Explanations about Log4j concepts, I would introduce Log4j in practice through several concrets examples and their results.
The section of this article will be:
1) Use of Log4j directly
2) Specifying granularity for external library or for custom package
3) Use of Log4j with a wrapper
4) Extended example with DailyRollingFileAppender
5) Use of environment variables in Log4J
6) Configure ...more»
