Skip to content
Snippets Groups Projects
Commit 461d6588 authored by Vincent Massol's avatar Vincent Massol
Browse files

XWIKI-20443: Jetty standalone doesn't save logs to files anymore

parent c5892e90
No related branches found
No related tags found
No related merge requests found
......@@ -58,5 +58,25 @@ We brought the following changes from the default Jetty files obtained from the
http-forwarded
```
7. Addition of `modules/xwiki-logging.mod` to configure logging for XWiki (provides the Jetty `logging` module name)
8. Note that we don't include all `etc/*.xml` files nor all `modules/*.mod` files since we don't use these extra
8. Modification of `etc/console-capture.xml` to send logs to both the console and files. Namely we wrapp:
```
<Arg>
<New class="org.eclipse.jetty.util.RolloverFileOutputStream">
...
</Arg>
```
With:
```
<Arg>
<!-- XWiki wants to log to both the console and also to file, and thus we're wrapping the RolloverFileOutputStream
class with a TeeOutputStream to split the logs. -->
<New class="org.apache.commons.io.output.TeeOutputStream">
...
<!-- Since we can't send to both out and err, we choose to send to out since logs are not errors by default,
so it seems the most logical one to use -->
<Arg><Get class="java.lang.System" name="out"/></Arg>
</New>
</Arg>
```
9. Note that we don't include all `etc/*.xml` files nor all `modules/*.mod` files since we don't use these extra
features.
<?xml version="1.0" encoding="UTF-8"?>
<!--
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">
<Configure id="logging">
<New id="ServerLog" class="java.io.PrintStream">
<Arg>
<!-- XWiki wants to log to both the console and also to file, and thus we're wrapping the RolloverFileOutputStream
class with a TeeOutputStream to split the logs. -->
<New class="org.apache.commons.io.output.TeeOutputStream">
<Arg>
<New class="org.eclipse.jetty.util.RolloverFileOutputStream">
<Arg><Property name="jetty.console-capture.dir" default="./logs" />/yyyy_mm_dd.jetty.log
</Arg>
<Arg type="boolean">
<Property name="jetty.console-capture.append" default="false" />
</Arg>
<Arg type="int">
<Property name="jetty.console-capture.retainDays" default="90" />
</Arg>
<Arg>
<Call class="java.util.TimeZone" name="getTimeZone">
<Arg>
<Property name="jetty.console-capture.timezone" default="GMT" />
</Arg>
</Call>
</Arg>
<Get id="ServerLogName" name="datedFilename" />
</New>
</Arg>
<!-- Since we can't send to both out and err, we choose to send to out since logs are not errors by default,
so it seems the most logical one to use -->
<Arg><Get class="java.lang.System" name="out"/></Arg>
</New>
</Arg>
</New>
<Call class="org.slf4j.LoggerFactory" name="getLogger">
<Arg>org.eclipse.jetty</Arg>
<Call name="info">
<Arg>Console stderr/stdout captured to
<Ref refid="ServerLogName" />
</Arg>
</Call>
</Call>
<Call class="java.lang.System" name="setErr">
<Arg>
<Ref refid="ServerLog" />
</Arg>
</Call>
<Call class="java.lang.System" name="setOut">
<Arg>
<Ref refid="ServerLog" />
</Arg>
</Call>
</Configure>
# ---------------------------------------------------------------------------
# See the NOTICE file distributed with this work for additional
# information regarding copyright ownership.
#
# This is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this software; if not, write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
# ---------------------------------------------------------------------------
# DO NOT EDIT - See: https://www.eclipse.org/jetty/documentation/
[description]
Redirects the JVM console stderr and stdout to a rolling log file.
[tags]
logging
[depends]
logging
[xml]
etc/console-capture.xml
[files]
logs/
[ini-template]
# tag::documentation[]
## Logging directory (relative to $JETTY_BASE).
# jetty.console-capture.dir=./logs
## Whether to append to existing file.
# jetty.console-capture.append=true
## How many days to retain old log files.
# jetty.console-capture.retainDays=90
## Timezone ID of the log timestamps, as specified by java.time.ZoneId.
# jetty.console-capture.timezone=GMT
# end::documentation[]
......@@ -20,7 +20,7 @@
[description]
Base configuration for the jetty logging mechanism.
Provides a ${jetty.base}/resources/jetty-logging.properties.
Logs are configured through ${jetty.base}/resources/jetty-logging.properties.
[depend]
resources
......
......@@ -32,6 +32,7 @@ deploy
requestlog
websocket
apache-jsp
console-capture
[xml]
etc/jetty-xwiki.xml
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment