log4j
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
log4j [2015/08/14 08:08] – skip | log4j [2020/12/27 20:35] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ==== Adding Configurations ==== | ||
+ | Rules: | ||
+ | - The configuration has to be stored in classpath. (In eclipse RCP you can store it in a Fragment) | ||
+ | - The path is set relatively to the classpath folders | ||
+ | - The path can be passed sa a JVM attribute: | ||
+ | < | ||
+ | -Dlog4j.configuration=/ | ||
+ | </ | ||
+ | |||
+ | |||
+ | Example properties File: | ||
+ | |||
+ | < | ||
+ | # Set root logger level to DEBUG and its only appender to Console. | ||
+ | log4j.rootCategory=INFO, | ||
+ | log4j.category.de.ivu=DEBUG, | ||
+ | log4j.additivity.de.ivu=false | ||
+ | log4j.category.de.ivu.fare.rcp.gui.accordion=ERROR | ||
+ | |||
+ | ################## | ||
+ | # general appender | ||
+ | ################## | ||
+ | # console | ||
+ | log4j.appender.others=org.apache.log4j.ConsoleAppender | ||
+ | log4j.appender.others.layout=org.apache.log4j.PatternLayout | ||
+ | log4j.appender.others.layout.ConversionPattern=*GENERAL* %d <%t> [%p] %c - %m%n | ||
+ | log4j.appender.others.Threshold=WARN | ||
+ | |||
+ | ################## | ||
+ | # ivu appender | ||
+ | ################## | ||
+ | # console | ||
+ | log4j.appender.IVUconsole=org.apache.log4j.ConsoleAppender | ||
+ | log4j.appender.IVUconsole.layout=org.apache.log4j.PatternLayout | ||
+ | log4j.appender.IVUconsole.layout.ConversionPattern=*OVU-LOG* %d <%t> [%p] %c - %m%n | ||
+ | log4j.appender.IVUconsole.Threshold=DEBUG | ||
+ | |||
+ | # file | ||
+ | log4j.appender.IVUfile=org.apache.log4j.RollingFileAppender | ||
+ | log4j.appender.IVUfile.File=./ | ||
+ | log4j.appender.IVUfile.MaxFileSize=2048KB | ||
+ | log4j.appender.IVUfile.MaxBackupIndex=3 | ||
+ | log4j.appender.IVUfile.layout=org.apache.log4j.PatternLayout | ||
+ | log4j.appender.IVUfile.layout.ConversionPattern=*OVU-LOG* %d <%t> [%p] %c - %m%n | ||
+ | log4j.appender.IVUfile.Threshold=DEBUG | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Property Substitution ==== | ||
+ | It is possible to use system properties / environment variables etc. inside the log4j configuration. | ||
+ | The syntax looks as following: | ||
+ | < | ||
+ | ${env: | ||
+ | ${sys: | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | All the details about the sysntax and all possible substitution sources are listed here: \\ https:// | ||
+ | |||
+ | |||
+ | ==== FILTER ==== | ||
+ | |||
+ | Filter may be used to filter out some stuff. | ||
+ | |||
+ | E.g. the RegEx Filter is very powerfull and may be placed directly inside the configuraiton, | ||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ |