Could not create a Pier Use Log for Recording

I followed this page
to install jetty on a Amazon EC2 instance of mine (Ubuntu 14.04.2 LTS). Jetty is running. However, I can’t make it use logback for logging. Below are relevant information. What did I do wrong here?

service check

$ service jetty check
Checking arguments to Jetty:
START_INI      =  /opt/jetty/start.ini
START_D        =  /opt/jetty/start.d
JETTY_HOME     =  /opt/jetty
JETTY_BASE     =  /opt/jetty
JETTY_CONF     =  /opt/jetty/etc/jetty.conf
JETTY_PID      =  /tmp/jetty.pid
JETTY_START    =  /opt/jetty/start.jar
JETTY_LOGS     =  /opt/jetty/logs
JETTY_STATE    =  /opt/jetty/jetty.state
CLASSPATH      =
JAVA           =  /usr/bin/java
JAVA_OPTIONS   =  -Djetty.logs=/opt/jetty/logs -Djetty.home=/opt/jetty -Djetty.base=/opt/jetty -Djava.io.tmpdir=/tmp
JETTY_ARGS     =  jetty.state=/opt/jetty/jetty.state jetty-started.xml
RUN_CMD        =  /usr/bin/java -Djetty.logs=/opt/jetty/logs -Djetty.home=/opt/jetty -Djetty.base=/opt/jetty -Djava.io.tmpdir=/tmp -jar /opt/jetty/start.jar jetty.state=/opt/jetty/jetty.state jetty-started.xml

/etc/default/jetty

$ cat /etc/default/jetty
# Defaults for jetty see /etc/init.d/jetty for more

# change to 0 to allow Jetty to start
NO_START=0

# change to 'no' or uncomment to use the default setting in /etc/default/rcS
VERBOSE=yes

# Run Jetty as this user ID (default: jetty)
# Set this to an empty string to prevent Jetty from starting automatically
JETTY_USER=jetty

# Listen to connections from this network host
# Use 0.0.0.0 as host to accept all connections.
# Uncomment to restrict access to localhost
JETTY_HOST=0.0.0.0

# The network port used by Jetty
JETTY_PORT=8080

# Timeout in seconds for the shutdown of all webapps
JETTY_SHUTDOWN=30

# Additional arguments to pass to Jetty
#JETTY_ARGS=

# Extra options to pass to the JVM
#JAVA_OPTIONS="-Xmx256m -Djava.awt.headless=true -Djava.library.path=/usr/lib"

# Home of Java installation.
JAVA=/usr/bin/java
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
JETTY_HOME=/opt/jetty

# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not
# defined in /etc/default/jetty). Should contain a list of space separated directories.
#JDK_DIRS="/usr/lib/jvm/default-java /usr/lib/jvm/java-6-sun"

# Java compiler to use for translating JavaServer Pages (JSPs). You can use all
# compilers that are accepted by Ant's build.compiler property.
#JSP_COMPILER=jikes

# Jetty uses a directory to store temporary files like unpacked webapps
#JETTY_TMP=/var/cache/jetty

# Jetty uses a config file to setup its boot classpath
#JETTY_START_CONFIG=/etc/jetty/start.config

# Default for number of days to keep old log files in /var/log/jetty/
#LOGFILE_DAYS=14

/opt/jetty/etc/jetty.conf

$ cat /opt/jetty/etc/jetty.conf
# ========================================================
# jetty.conf Configuration for jetty.sh script
# --------------------------------------------------------
# This file is used by the jetty.sh script to provide
# extra configuration arguments for the start.jar command
# created by that script.
#
# Each line in this file becomes an arguement to start.jar
# in addition to those found in the start.ini file
# =======================================================
#jetty-logging.xml
jetty-started.xml

/opt/jetty/modules/logging.mod

$ cat /opt/jetty/modules/logging.mod
#
# Jetty std err/out logging
#

[name]
logging

[files]
logs/

[lib]
lib/logging/*.jar
resources/

[ini-template]
## Logging Configuration
# Configure jetty logging for default internal behavior STDERR output
# -Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog

# Configure jetty logging for slf4j
-Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.Slf4jLog

# Configure jetty logging for java.util.logging
# -Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.JavaUtilLog

# STDERR / STDOUT Logging
# Number of days to retain logs
# jetty.log.retain=90
# Directory for logging output
# Either a path relative to ${jetty.base} or an absolute path
# jetty.logs=logs

/opt/jetty/resources/logback.xml

$ cat /opt/jetty/resources/logback.xml


    
    

    
    
        
            %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{100} - %msg%n
        
    

    
        /opt/jetty/logs/server.log
        
            
            /opt/jetty/logs/server.%d{yyyy-MM-dd}.log

            
            30
        

        
            %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{100} - %msg%n
        
    

    
    
    

    
        
        
    

/opt/jetty/start.ini

$ cat /opt/jetty/start.ini
#===========================================================
# Jetty Startup
#
# Starting Jetty from this {jetty.home} is not recommended.
#
# A proper {jetty.base} directory should be configured, instead
# of making changes to this {jetty.home} directory.
#
# See documentation about {jetty.base} at
# http://www.eclipse.org/jetty/documentation/current/startup.html
#
# A demo-base directory has been provided as an example of
# this sort of setup.
#
# $ cd demo-base
# $ java -jar ../start.jar
#
#===========================================================

# To disable the warning message, comment the following line
--module=home-base-warning

# ---------------------------------------
# Module: server
--module=server
##
## Server Threading Configuration
##
# minimum number of threads
threads.min=10
# maximum number of threads
threads.max=200
# thread idle timeout in milliseconds
threads.timeout=60000
# buffer size for output
jetty.output.buffer.size=32768
# request header buffer size
jetty.request.header.size=8192
# response header buffer size
jetty.response.header.size=8192
# should jetty send the server version header?
jetty.send.server.version=true
# should jetty send the date header?
jetty.send.date.header=false
# What host to listen on (leave commented to listen on all interfaces)
#jetty.host=0.0.0.0
# Dump the state of the Jetty server, components, and webapps after startup
jetty.dump.start=false
# Dump the state of the Jetty server, before stop
jetty.dump.stop=false
# Enable delayed dispatch optimisation
jetty.delayDispatchUntilContent=false

# ---------------------------------------
# Module: deploy
--module=deploy
## DeployManager configuration
# Monitored Directory name (relative to jetty.base)
# jetty.deploy.monitoredDirName=webapps

# ---------------------------------------
# Module: websocket
--module=websocket

# ---------------------------------------
# Module: ext
--module=ext

# ---------------------------------------
# Module: resources
--module=resources

# ---------------------------------------
# Module: jsp
--module=jsp
# JSP Configuration

# Select JSP implementation, choices are
#   glassfish : The reference implementation
#               default in jetty = 9.2
jsp-impl=apache

# To use a non-jdk compiler for JSP compilation when using glassfish uncomment next line
# -Dorg.apache.jasper.compiler.disablejsr199=true

# ---------------------------------------
# Module: jstl
--module=jstl
# JSTL Configuration
# The glassfish jsp-impl includes JSTL by default and this module
# is not required to activate it.
# The apache jsp-impl does not include JSTL by default and this module
# is required to put JSTL on the container classpath

#
# Initialize module logging
#
--module=logging

# ---------------------------------------
# Module: http
--module=http
### HTTP Connector Configuration
-Djava.net.preferIPv4Stack=true

## HTTP port to listen on
jetty.port=8080

## HTTP idle timeout in milliseconds
http.timeout=30000

## HTTP Socket.soLingerTime in seconds. (-1 to disable)
# http.soLingerTime=-1

## Parameters to control the number and priority of acceptors and selectors
# http.selectors=1
# http.acceptors=1
# http.selectorPriorityDelta=0
# http.acceptorPriorityDelta=0

First (and most important) don’t change, edit, modify, add, remove, delete, mangle, rename, touch, etc anything in ${jetty.home}

That is your jetty-distribution directory, its not meant to be changed, unpack it, then leave it alone.

It even tells you this when you startup!

2015-05-06 06:34:58.838:WARN:oejs.HomeBaseWarning:main: This instance of Jetty is not
running from a separate {jetty.base} directory, this is not recommended.
See documentation at http://www.eclipse.org/jetty/documentation/current/startup.html
2015-05-06 06:34:58.959:INFO:oejs.Server:main: jetty-9.2.10.v20150310

To fix this:

Start by creating a new directory somewhere (anywhere) this will become your ${jetty.base}

The ${jetty.base}
directory is where you configure your instance of a running Jetty.

The documentation has instructions on 3 different configurations for logback in a ${jetty.base}

If you follow those directions, you’ll wind up with:

  • a ${jetty.base}
    that has a start.ini
    for you
  • the libraries you’ll need in ${jetty.base}/lib/logging
  • an overridden ${jetty.base}/modules/logging.mod
  • the logback configuration in ${jetty.base}/resources/logback.xml
  • the jetty logging configuration in ${jetty.base}/resources/jetty-logging.properties

From here you setup the rest of the modules you’ll need in ${jetty.base}/start.ini
along with your webapps and other bits and bobs you’ll need (never once editing ${jetty.home}
)

Finally, you’ll edit your /etc/default/jetty
to add a JETTY_BASE
that points to this directory.

To test if this ${jetty.base}
configuration makes sense, you’ll use the command line.

CD into your new ${jetty.base}
and run

[mybase]$ java -jar /path/to/jetty-dist/start.jar

That will start up that configuration as a normal process (not a service), from which you’ll be able to see if the configuration is behaving the way you need it to.

Hello, buddy!稿源:Hello, buddy! (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 综合编程 » Could not create a Pier Use Log for Recording

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录