Logging

From Resin 3.0

(Difference between revisions)
Jump to: navigation, search
(migration)
(migration)
Line 5: Line 5:
 
{{main|access-log}}
 
{{main|access-log}}
  
An access log is a log that receives output describing each request received by
+
An access log receives output describing each request received by
the server.  It is commonly used in conjunction with analyzing tools to
+
the server.  It is commonly used in conjunction with analysis tools to
 
determine statistics and patterns of use for a website.
 
determine statistics and patterns of use for a website.
  
Line 28: Line 28:
 
=== Examples ===
 
=== Examples ===
  
[[resin.conf]] configuration to capture [[Sysyem.out]] and [[System.err]]
+
[[resin.conf]] configuration to capture [[System.out]] and [[System.err]]
 
output to log files.
 
output to log files.
  
Line 52: Line 52:
 
JDK.  Log messages have a ''name'' and and a ''level''.  
 
JDK.  Log messages have a ''name'' and and a ''level''.  
  
Some [[Resin logging names]] have been documented.
+
Logging can be used to enable [[Resin logging names]] and to enable application specific logging that utilizes the JDK logging facilities.
  
 
=== Examples ===
 
=== Examples ===
  
Capture ''finer'' logging and display it on the console, useful during
+
resin.conf configuration to capture ''finer'' logging and display it on the
development:
+
console, useful during development:
  
 
<!--  pre -->
 
<!--  pre -->
 
+
  <resin xmlns="http://caucho.com/ns/resin"
  <resin>
+
        xmlns:resin="http://caucho.com/ns/resin/core">
 
   ...
 
   ...
 
   <log name="" level="finer" path="stdout:"/>
 
   <log name="" level="finer" path="stdout:"/>
 
   ...
 
   ...
 
  </resin>
 
  </resin>
 
 
<!-- /pre -->
 
<!-- /pre -->
  
== Rollover directives ==
+
resin.conf configuration to capture ''finer'' request and response related
 +
logging from Resin, and all logging from the ''com.hogwarts'' application under
 +
development:
  
{{main|Rollover}}
+
<!-- pre -->
 +
<resin xmlns="http://caucho.com/ns/resin"
 +
        xmlns:resin="http://caucho.com/ns/resin/core">
 +
 
 +
  <!-- log request and response info -->
 +
  <log path='stdout:' timestamp='[%H:%M:%S.%s] '>
 +
    <logger name="com.caucho.server.port.TcpConnection" level="fine"/>
 +
    <logger name="com.caucho.server.http.HttpRequest" level="fine"/>
 +
    <logger name="com.caucho.server.connection.AbstractHttpResponse" level="fine"/>
 +
 
 +
    <logger name="com.hogwarts" level="all"/>
 +
  </log>
 +
 
 +
  ...
 +
 
 +
</resin>
 +
<!-- /pre -->
  
Rollover directives indicate that log files should be rolled over to new names
+
== Archiving ==
at specified frequencies, breaking ever growing log files into manageable
+
chunks.
+
  
== Archiving directives ==
+
All log directives support archiving, when the log reaches a certain size or
 +
age a rollover occurs and the existing log is saved away while a new log is
 +
started. 
  
{{main|Archiving}}
+
'''path-format''' and '''archive-format''' are two mutually exclusive methods
 +
for archiving logs.  ''Rollover'' determines the frequency at which the archive
 +
files are created.
  
'''archive-format''' and '''path-format''' are two mutually exclusive methods
+
=== path-format ===
for archiving logs.
+
  
path-format specifies the name of a file to write the log to, and the name
+
<tt>path-format</tt> specifies the name of a file. The name contains
contains [[date format]]  escape sequences that are replaced with the current
+
[[date format]]  escape sequences that are replaced with the current date and
date and time.
+
time.  When the rollover occurs, a new file is started with the appropriate
 +
date and time.  Thus <tt>path-format</tt> results in archive files that are
 +
named with the date and time of the first entry in the log.
  
 
  ...
 
  ...
Line 96: Line 116:
 
  ...
 
  ...
  
archive-format first writes to a file specified by
+
=== archive-format and path ===
[[path]], and then copies the file to the archive name at rollover time.
+
  
The file specified wth archive-format contains [[date format]]
+
Log messages are written to the file specified by <tt>[[path]]</tt>.
escape sequences that are replaced with the current date and time.
+
When a rollover occurs the contents of the file are copied to the
 +
<tt>archive-path</tt>.  The <tt>archive-path</tt> contains [[date format]]
 +
escape sequences that are replaced with the current date and time.  Thus
 +
archive-format results in log files that are named with the date and time of
 +
the last entry in the log.
  
 
archive-format can use a *.gz or *.zip extension to indicate that the
 
archive-format can use a *.gz or *.zip extension to indicate that the
Line 109: Line 132:
 
             rollover-period="1D"/>
 
             rollover-period="1D"/>
  
== See also==
+
=== Rollover ===
  
; [[Redirecting standard output]] :
+
The fequency of the rollover is is specified with [[rollover-period]] or
 +
[[rollover-size]].
 +
 
 +
<tt>rollover-period</tt> is a time based specification of a [[period]] in days
 +
(15D), weeks (2W), months (1M), or hours (1h).  When the specified time period
 +
has elapsed the rollover occurs.
 +
 
 +
<tt>rollover-size</tt> is a size based specification of a [[size]] in bytes
 +
(50000), kb (128kb), or megabytes (10mb).  When the log reaches the specified
 +
size the rollover occurs.
 +
 
 +
=== Disabling rollover ===
 +
 
 +
To completely disable rollovers, set the rollover-size to such a high number
 +
that it will never occur:
 +
 
 +
<!-- pre -->
 +
  <stdout-log path="log/stdout.log" rollover-size="1024mb"/>
 +
<!-- /pre -->

Revision as of 17:49, 28 February 2006


Contents

Access logging

Main article: access-log

An access log receives output describing each request received by the server. It is commonly used in conjunction with analysis tools to determine statistics and patterns of use for a website.

Examples

<access-log path="logs/access.log"
            format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'
            rollover-period="1W"/>


stdout-log and stderr-log

Main article: stdout-log
Main article: stderr-log

The stdout-log and stderr-log directives capture and redirect the output of System.out and System.err.

Examples

resin.conf configuration to capture System.out and System.err output to log files.


<resin xmlns="http://caucho.com/ns/resin"
       xmlns:resin="http://caucho.com/ns/resin/core">

  <stdout-log path='/var/log/foo/stdout.log'
              rollover-period='1W'/>
  <stderr-log path='/var/log/foo/stderr.log'
              rollover-period='1W'/>
 
  ...


log

Main article: log

Java programs (including Resin) can use the logging facilities included in the JDK. Log messages have a name and and a level.

Logging can be used to enable Resin logging names and to enable application specific logging that utilizes the JDK logging facilities.

Examples

resin.conf configuration to capture finer logging and display it on the console, useful during development:

<resin xmlns="http://caucho.com/ns/resin"
       xmlns:resin="http://caucho.com/ns/resin/core">
  ...
  <log name="" level="finer" path="stdout:"/>
  ...
</resin>

resin.conf configuration to capture finer request and response related logging from Resin, and all logging from the com.hogwarts application under development:

<resin xmlns="http://caucho.com/ns/resin"
       xmlns:resin="http://caucho.com/ns/resin/core">
 
  <log path='stdout:' timestamp='[%H:%M:%S.%s] '>
    <logger name="com.caucho.server.port.TcpConnection" level="fine"/>
    <logger name="com.caucho.server.http.HttpRequest" level="fine"/>
    <logger name="com.caucho.server.connection.AbstractHttpResponse" level="fine"/>
 
    <logger name="com.hogwarts" level="all"/>
  </log>
 
  ...
  
</resin>

Archiving

All log directives support archiving, when the log reaches a certain size or age a rollover occurs and the existing log is saved away while a new log is started.

path-format and archive-format are two mutually exclusive methods for archiving logs. Rollover determines the frequency at which the archive files are created.

path-format

path-format specifies the name of a file. The name contains date format escape sequences that are replaced with the current date and time. When the rollover occurs, a new file is started with the appropriate date and time. Thus path-format results in archive files that are named with the date and time of the first entry in the log.

...
<host id="www.foo.com">
   <access-log path-format="/var/www/log/%Y/%m/%d.access.log"
               rollover-period="1D"/>
   ... 
</host>
...

archive-format and path

Log messages are written to the file specified by path. When a rollover occurs the contents of the file are copied to the archive-path. The archive-path contains date format escape sequences that are replaced with the current date and time. Thus archive-format results in log files that are named with the date and time of the last entry in the log.

archive-format can use a *.gz or *.zip extension to indicate that the archived log should be compressed.

<access-log path="log/access.log"
            archive-path="/var/www/log/access.log.%Y%m%d.gz"
            rollover-period="1D"/>

Rollover

The fequency of the rollover is is specified with rollover-period or rollover-size.

rollover-period is a time based specification of a period in days (15D), weeks (2W), months (1M), or hours (1h). When the specified time period has elapsed the rollover occurs.

rollover-size is a size based specification of a size in bytes (50000), kb (128kb), or megabytes (10mb). When the log reaches the specified size the rollover occurs.

Disabling rollover

To completely disable rollovers, set the rollover-size to such a high number that it will never occur:

 <stdout-log path="log/stdout.log" rollover-size="1024mb"/>
Personal tools