There seems to be some confusion here.

*Jetty Logging *

Jetty Logging refers to the server side logging, not webapp.
While it's possible to use from a webapp, its actually easier to use a
formal logging library (like slf4j, logback, log4j, java.util.logging, etc)

*logs/yyyy_mm_dd.request.log *

The files ...

    /var/log/jetty/ws-slova.de/2017_08_30.request.log
    /var/log/jetty/slova.de/2017_08_30.request.log

... are request logs, aka NCSA access logging.
These are not related to server logging, and do not use the Server logging
framework.

*jetty-logging.properties location*

The file jetty-logging.properties can exist as a resource that the
classloader can access.

>From the server classloader point of view, that file is accessed from

   ${jetty.base}/resources/jetty-logging.properties

>From a webapp classloader point of view, that file is accessed from your


 ${jetty.base}/webapps/<appname>.war!/WEB-INF/classes/jetty-logging.properties

It is strongly discouraged to change the logging behavior of the Jetty
Logging infrastructure from within a webapp, as it can make changes to the
server side as well.

We would encourage you to setup a some formal logging library in your
webapp (having more then 1 logging library in your webapp is extremely
common btw)

*jetty-logging.properties configuration*

The first line in the jetty-logging.properties dictates the logging
technique to use.

   org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog

The StdErrLog is the default behavior, and will produce logging events to
STDERR (aka System Error.  like System.err.println("hello"))

This produces no log files, it only shows up on the console on the STDERR
streams.

*Console Capture *

If you configure for logging on Jetty 9.4.x you'll see a module called
"console-capture".
That simply takes whatever is being written to the console, on either
STDOUT (System out) or STDERR (System error) and redirects it to a file
with rolling.

*Jetty Server Logging Configuration *

You can configure Jetty server logging to use something other then
StdErrLog + Console Capture.

Two very common techniques:

   1. java.util.logging - configure
   org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.JavaUtilLog
   2. slf4j + logback - configure
   org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.Slf4jLog




Joakim Erdfelt / [email protected]

On Wed, Aug 30, 2017 at 2:12 AM, Alexander Farber <
[email protected]> wrote:

> Good morning,
>
> on CentOS 7 Linux I have installed Jetty as:
>
> # java -jar /usr/share/java/jetty-distribution-9.4.6.v20170531/start.jar
> jetty.home=/usr/share/java/jetty-distribution-9.4.6.v20170531
> jetty.base=/var/www/jetty-base --create-startd --add-to-start=http,servlet,
> webapp,deploy,resources,fcgi,websocket,proxy-protocol
>
> and then start it as:
>
> java -Djdbc.drivers=org.postgresql.Driver -jar /usr/share/java/jetty-
> distribution-9.4.6.v20170531/start.jar jetty.home=/usr/share/java/
> jetty-distribution-9.4.6.v20170531 jetty.base=/var/www/jetty-base
> jetty.http.host=127.0.0.1
>
> In $JETTY_BASE/webapps I have 2 files to run my app (a custom
> WebSocketServlet) and to proxy Wordpress -
>
> 1) ws-slova.de.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
>     "http://www.eclipse.org/jetty/configure_9_0.dtd";>
> <Configure class="org.eclipse.jetty.webapp.WebAppContext">
>
>     <Set name="contextPath">/ws</Set>
>
>     <Set name="virtualHosts">
>             <Array type="java.lang.String">
>                     <Item>slova.de</Item>
>                     <Item>www.slova.de</Item>
>             </Array>
>     </Set>
>
>     <Set name="war"><SystemProperty name="jetty.base"/>/webapps/
> ws-servlet-0.1-SNAPSHOT.war</Set>
>
>     <Call name="insertHandler">
>         <Arg>
>             <New id="RequestLog" class="org.eclipse.jetty.server.handler.
> RequestLogHandler">
>                 <Set name="requestLog">
>                     <New id="RequestLogImpl" class="org.eclipse.jetty.
> server.NCSARequestLog">
>                         <Set name="filename">/var/log/jetty/
> ws-slova.de/yyyy_mm_dd.request.log</Set>
>                         <Set name="filenameDateFormat">yyyy_MM_dd</Set>
>                         <Set name="LogTimeZone">GMT</Set>
>                         <Set name="retainDays">30</Set>
>                         <Set name="append">true</Set>
>                     </New>
>                 </Set>
>             </New>
>         </Arg>
>     </Call>
>
> </Configure>
>
> 2)  slova.de.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
>     "http://www.eclipse.org/jetty/configure_9_3.dtd";>
> <Configure class="org.eclipse.jetty.servlet.ServletContextHandler">
>
>     <New id="root" class="java.lang.String">
>         <Arg>/var/www/html/slova.de</Arg>
>     </New>
>
>     <Set name="contextPath">/</Set>
>
>     <Set name="virtualHosts">
>             <Array type="java.lang.String">
>                     <Item>slova.de</Item>
>                     <Item>www.slova.de</Item>
>             </Array>
>     </Set>
>
>     <Set name="resourceBase"><Ref refid="root" /></Set>
>
>     <Set name="welcomeFiles">
>         <Array type="string">
>                 <Item>index.html</Item>
>                 <Item>index.php</Item>
>         </Array>
>     </Set>
>
>     <Call name="addFilter">
>         <Arg>org.eclipse.jetty.fcgi.server.proxy.TryFilesFilter</Arg>
>         <Arg>/*</Arg>
>         <Arg>
>             <Call name="of" class="java.util.EnumSet">
>                 <Arg><Get name="REQUEST" class="javax.servlet.DispatcherType"
> /></Arg>
>             </Call>
>         </Arg>
>         <Call name="setInitParameter">
>             <Arg>files</Arg>
>             <Arg>$path /index.php?p=$path</Arg>
>         </Call>
>     </Call>
>
>     <Call name="addServlet">
>         <Arg>
>             <New class="org.eclipse.jetty.servlet.ServletHolder">
>                 <Arg>default</Arg>
>                 <Arg>
>                     <Call name="forName" class="java.lang.Class">
>                         <Arg>org.eclipse.jetty.
> servlet.DefaultServlet</Arg>
>                     </Call>
>                 </Arg>
>                 <Call name="setInitParameter">
>                     <Arg>dirAllowed</Arg>
>                     <Arg>false</Arg>
>                 </Call>
>                 <Call name="setInitParameter">
>                     <Arg>gzip</Arg>
>                     <Arg>true</Arg>
>                 </Call>
>             </New>
>         </Arg>
>         <Arg>/</Arg>
>     </Call>
>
>     <Call name="addServlet">
>         <Arg>org.eclipse.jetty.fcgi.server.proxy.FastCGIProxyServlet</Arg>
>         <Arg>*.php</Arg>
>         <Call name="setInitParameter">
>             <Arg>proxyTo</Arg>
>             <Arg>http://localhost:9000</Arg>
>         </Call>
>         <Call name="setInitParameter">
>             <Arg>prefix</Arg>
>             <Arg>/</Arg>
>         </Call>
>         <Call name="setInitParameter">
>             <Arg>scriptRoot</Arg>
>             <Arg><Ref refid="root" /></Arg>
>         </Call>
>         <Call name="setInitParameter">
>             <Arg>scriptPattern</Arg>
>             <Arg>(.+?\\.php)</Arg>
>         </Call>
>     </Call>
>
>     <Call name="insertHandler">
>         <Arg>
>             <New id="RequestLog" class="org.eclipse.jetty.server.handler.
> RequestLogHandler">
>                 <Set name="requestLog">
>                     <New id="RequestLogImpl" class="org.eclipse.jetty.
> server.NCSARequestLog">
>                         <Set name="filename">/var/log/jetty/
> slova.de/yyyy_mm_dd.request.log</Set>
>                         <Set name="filenameDateFormat">yyyy_MM_dd</Set>
>                         <Set name="LogTimeZone">GMT</Set>
>                         <Set name="retainDays">30</Set>
>                         <Set name="append">true</Set>
>                     </New>
>                 </Set>
>             </New>
>         </Arg>
>     </Call>
>
> </Configure>
>
> This works well, but I have one problem - in the log files
>
>     /var/log/jetty/ws-slova.de/2017_08_30.request.log
>
>     /var/log/jetty/slova.de/2017_08_30.request.log
>
> I do not see any output by java directives LOG.info and LOG.warn, which I
> call in my servlet as -
>
> import org.eclipse.jetty.util.log.Log;
> import org.eclipse.jetty.util.log.Logger;
>
> public static final Logger LOG = Log.getLogger("slova");
>
> public class MyListener implements WebSocketListener {
>
>     @Override
>     public void onWebSocketConnect(Session session) {
>         LOG.info("onWebSocketConnect: {}", session);            //
> UNFORTUNATELY I DO NOT SEE THIS
>         mSession = session;
>     }
>
> I have read https://www.eclipse.org/jetty/documentation/9.4.x/
> configuring-logging.html but I am still confused, what should I do? The
> doc talks about jetty-logging.properties file, should I create one?
>
> Currently there is only one such file in $JETTY_HOME:
>
> # cat /usr/share/java/jetty-distribution-9.4.6.v20170531/
> modules/logging-jetty/resources/jetty-logging.properties
>
> ## Force jetty logging implementation
> #org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
>
> ## Set logging levels from: ALL, DEBUG, INFO, WARN, OFF
> #org.eclipse.jetty.LEVEL=INFO
> #com.example.LEVEL=INFO
>
> ## Hide stacks traces in logs?
> #com.example.STACKS=false
>
> ## Show the source file of a log location?
> #com.example.SOURCE=false
>
> Am I really supposed to edit that file? I was thinking $JETTY_HOME files
> are not to be touched.
>
> Regards
> Alex
>
>
>
>
>
>
> _______________________________________________
> jetty-users mailing list
> [email protected]
> To change your delivery options, retrieve your password, or unsubscribe
> from this list, visit
> https://dev.eclipse.org/mailman/listinfo/jetty-users
>
_______________________________________________
jetty-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to