Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Forked Jetty: complete logging?

You seem to be using the default logging of letting Jetty use its internal StdErrLog, and then the System.out and System.err routing to a rolling file.

Jenkins is likely getting in the way at the System.out and System.err rerouting part.

At this point, I'd recommend you configure Jetty to use a more formal logging framework.
Something like Slf4J or java.util.logging.

Here's some help in how Jetty Logging works and is configured, with specifics for StdErrLog
http://wiki.eclipse.org/Jetty/Feature/Jetty_Logging

We also have a few examples for Slf4J that are documented at
http://wiki.eclipse.org/Jetty/Tutorial/Sifting_Logs_with_Logback

--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
webtide.com
Developer advice, services and support
from the Jetty & CometD experts
eclipse.org/jetty - cometd.org



On Tue, Nov 6, 2012 at 7:17 AM, Fhomasp <thomas.peeters1@xxxxxxxxxx> wrote:
I've got this problem with starting a forked jetty using the
jetty-maven-plugin.  The problem only occurs when done by a Jenkins job.
When we execute the Maven command manually (on a server or local machine) we
cannot reproduce the problem because the forked jetty simply works.

This Jenkins job uses the same settings, environments, commands as when we
run the job manually using Maven3.

I adjusted the logging by configuring it in a jetty.xml file, but when the
server isn't working because of the Jenkins run there's only a very small
entry in the log files which tells us absolutely nothing.  I want to know
why the server isn't getting up, preferably by decent logging.
When we start the job in Jenkins but *don't use* a forked jetty there is no
problem...

Jetty.xml:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC &quot;-//Jetty//Configure//EN&quot;
&quot;http://www.eclipse.org/jetty/configure.dtd&quot;>
<Configure class="org.eclipse.jetty.server.Server">
    <Call name="addConnector">
        <Arg>
            <New
class="org.eclipse.jetty.server.nio.SelectChannelConnector">
                <Set name="port">8282</Set>
                <Set name="confidentialPort">1123</Set>
                <Set name="integralPort">1124</Set>
            </New>
        </Arg>
    </Call>

    <New id="ServerLog" class="java.io.PrintStream">
        <Arg>
            <New class="org.eclipse.jetty.util.RolloverFileOutputStream">
                <Arg><SystemProperty name="jetty.home"
default="/"/>/tmp/logs/yyyy_mm_dd.jetty-server.log</Arg>
                <Arg type="boolean">false</Arg>
                <Arg type="int">90</Arg>
                <Arg><Call class="java.util.TimeZone"
name="getTimeZone"><Arg>GMT</Arg></Call></Arg>
                <Get id="ServerLogName" name="datedFilename"/>
            </New>
        </Arg>
    </New>

    <Call class="org.eclipse.jetty.util.log.Log"
name="info"><Arg>Redirecting stderr/stdout to <Ref
id="ServerLogName"/></Arg></Call>
    <Call class="java.lang.System" name="setErr"><Arg><Ref
id="ServerLog"/></Arg></Call>
    <Call class="java.lang.System" name="setOut"><Arg><Ref
id="ServerLog"/></Arg></Call>



    <Set name="handler">
        <New id="Handlers"
class="org.eclipse.jetty.server.handler.HandlerCollection">
            <Set name="handlers">
                <Array type="org.eclipse.jetty.server.Handler">
                    <Item>
                        <New id="Contexts"
class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
                    </Item>
                    <Item>
                        <New id="DefaultHandler"
class="org.eclipse.jetty.server.handler.DefaultHandler"/>
                    </Item>
                    <Item>
                        <New id="RequestLog"
class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
                    </Item>
                </Array>
            </Set>
        </New>
    </Set>
    <Ref id="RequestLog">
        <Set name="requestLog">
            <New id="RequestLogImpl"
class="org.eclipse.jetty.server.NCSARequestLog">
                <Arg><SystemProperty name="jetty.logs"
default="/"/>/tmp/logs/yyyy_mm_dd.jetty-request.log</Arg>
                <Set name="retainDays">90</Set>
                <Set name="append">true</Set>
                <Set name="extended">true</Set>
                <Set name="LogTimeZone">GMT</Set>
            </New>
        </Set>
    </Ref>


</Configure>


pom.xml

                    <plugin>
                        <groupId>org.mortbay.jetty</groupId>
                        <artifactId>jetty-maven-plugin</artifactId>
                        <version>8.1.5.v20120716</version>
                        <configuration>
                            <stopKey>stopherding</stopKey>
                            <stopPort>${jetty.stopport}</stopPort>

<jettyXml>src/main/resources/env/${env}/jetty.xml</jettyXml>

                            <daemon>true</daemon>
                            <waitForChild>false</waitForChild>

<war>${project.build.directory}/${project.artifactId}-${project.version}.war</war>
                            <jvmArgs>-Denv=${env} -e -X</jvmArgs>
                            <webApp>
                                <contextPath>/bulk-uploader</contextPath>
                            </webApp>
                        </configuration>
                        <executions>
                            <execution>
                                <id>start-forked</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>run-forked</goal>
                                </goals>
                                <inherited>true</inherited>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>


Any input is welcome :-)



--
View this message in context: http://jetty.4.n6.nabble.com/Forked-Jetty-complete-logging-tp4959482.html
Sent from the Jetty User mailing list archive at Nabble.com.
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users


Back to the top