-
Notifications
You must be signed in to change notification settings - Fork 1
GSIP 167
Review our logging dependencies, part of updating libraries for Java 9 compatibility:
Jody Garnett
This proposal is for GeoServer 2.14
- Under Discussion
- In Progress
- Completed
- Rejected
- Deferred
We are using log4j 1 series which has ended, Log4J 2.8.2 and newer is compatible with Java jigsaw.
Updating the following:
library | version | upgrade |
---|---|---|
log4j | 1.2.17 | 2.11.1 |
org.slf4j | 1.6.4 | |
commons-logging | 1.1.1 | |
"java utility logging" | built-in |
Upgrading to log4j 2 provides:
- XML, JSON, YAML, or Java properties syntax (included nested properties)
- Compatibility with log4j 'chainsaw" GUI
- Log4j 1.2 as a small incompatibility with Java 11 that may or may not affect us.
For more information https://logging.apache.org/log4j/2.x/manual/configuration.html
GeoServer data directory contains named log4j configuration files, these log4j properties files are by their nature brittle and we should not expect to reuse them (they contain the class names of specific appenders which may of changed for log4j 2.x).
When configured with an empty data directory there is a series of "named" log4j property file configurations that are unpacked into the data directory folder.
Using this functionality:
- each time we can detect an old named "built-in" log4j properties file we could replace it with the one baked into the WAR.
- If the user has a custom configuration we will will not be able to load it
For information on configuration migration:
Project Steering Committee:
- Alessio Fabiani:
- Andrea Aime:
- Ben Caradoc-Davies:
- Brad Hards:
- Christian Mueller:
- Ian Turton:
- Jody Garnett: +1
- Jukka Rahkonen:
- Kevin Smith:
- Simone Giannecchini:
- https://interviewbubble.com/log4j-1-2-is-broken-on-java-9-java-logging/
- Log4j upgrade... like right now... yep, I mean it (geoserver-devel)
- https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout
- https://stackify.com/log4j2-java/
Log4j 1.2 DEFAULT_LOGGING.properties:
## This log4j configuration file needs to stay here, and is used as the default logging setup
## during data_dir upgrades and in case the chosen logging config isn't available.
log4j.rootLogger=WARN, geoserverlogfile, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{dd MMM HH:mm:ss} %p [%c{2}] - %m%n
log4j.appender.geoserverlogfile=org.apache.log4j.RollingFileAppender
# Keep three backup files.
log4j.appender.geoserverlogfile.MaxBackupIndex=3
# Pattern to output: date priority [category] - message
log4j.appender.geoserverlogfile.layout=org.apache.log4j.PatternLayout
log4j.appender.geoserverlogfile.layout.ConversionPattern=%d %p [%c{2}] - %m%n
log4j.category.log4j=FATAL
log4j.category.org.geotools=WARN
log4j.category.org.geotools.factory=WARN
log4j.category.org.geoserver=INFO
log4j.category.org.vfny.geoserver=INFO
log4j.category.org.springframework=WARN
log4j.category.org.geowebcache=INFO
log4j.category.org.geowebcache.seed.TruncateTask=WARN
Log4j 2.1 DEFAULT_LOGGING.xml:
- XML is the most common example
- Loggers are declared in the reverse order from most specific to least specific by convention, "additivity"
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="stout" target="SYSTEM_OUT">
<PatternLayout pattern="%d{dd MMM HH:mm:ss} [%t] %-5level %logger{2} - %m%n"/>
</Console>
<RollingFile name="geoserverlogfile"
fileName="logs/geoserver.log"
filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout>
<Pattern>%d %p [%c{2}] - %m%n</Pattern>
</PatternLayout>
<Policies>
<OnStartupTriggeringPolicy />
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="50 MB" />
</Policies>
<DefaultRolloverStrategy max="20" />
</RollingFile>
</Appenders>
<Loggers>
<Logger name="log4j.category.org.geowebcache.seed.TruncateTask" additivity="false" level="warn">
<AppenderRef ref="traceLog" />
<AppenderRef ref="Console" />
</Logger>
<Logger name="log4j.category.org.geowebcache" additivity="false" level="info">
<AppenderRef ref="traceLog" />
<AppenderRef ref="Console" />
</Logger>
<Logger name="log4j.category.org.springframework" additivity="false" level="warn">
<AppenderRef ref="traceLog" />
<AppenderRef ref="Console" />
</Logger>
<Logger name="log4j.category.org.vfny.geoserver" additivity="false" level="info">
<AppenderRef ref="traceLog" />
<AppenderRef ref="Console" />
</Logger>
<Logger name="log4j.category.org.geoserver" additivity="false" level="info">
<AppenderRef ref="traceLog" />
<AppenderRef ref="Console" />
</Logger>
<Logger name="log4j.category.org.geoserver" additivity="false" level="info">
<AppenderRef ref="traceLog" />
<AppenderRef ref="Console" />
</Logger>
<Root level="warn">
<AppenderRef ref="stout"/>
<AppenderRef ref="geoserverlog"/>
</Root>
</Loggers>
</Configuration>
©2020 Open Source Geospatial Foundation