Logging
From Resin 3.0
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[[Category:Configuration]] | [[Category:Configuration]] | ||
− | + | == Access logging == | |
− | + | {{main|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. | ||
− | + | See the main page for a description of all available configuration settings. | |
− | == | + | === Examples === |
− | < | + | <!-- pre --> |
+ | <access-log path="logs/access.log" | ||
+ | format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"' | ||
+ | rollover-period="1W"/> | ||
+ | <!-- /pre --> | ||
− | { | + | <!-- pre --> |
+ | <access-log path="logs/access.log" | ||
+ | format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"' | ||
+ | rollover-size="1mb"/> | ||
+ | <!-- /pre --> | ||
− | |||
− | + | == stdout-log and stderr-log == | |
− | + | {{main|stdout-log}} | |
+ | {{main|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. | |
− | + | ||
− | + | <!-- pre title="resin.conf" syntax="conf" --> | |
− | + | <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'/> | ||
+ | |||
+ | ... | ||
− | + | <!-- /pre --> | |
+ | == log == | ||
− | + | {{main|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: | ||
− | + | <!-- pre --> | |
+ | <resin xmlns="http://caucho.com/ns/resin" | ||
+ | xmlns:resin="http://caucho.com/ns/resin/core"> | ||
+ | ... | ||
+ | <log name="" level="finer" path="stdout:"/> | ||
+ | ... | ||
+ | </resin> | ||
+ | <!-- /pre --> | ||
− | + | resin.conf configuration to capture ''finer'' request and response related | |
− | + | logging from Resin, and all logging from the ''com.hogwarts'' application under | |
− | + | development: | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | <!-- 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 --> | ||
− | + | == 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 === |
+ | |||
+ | <tt>path-format</tt> 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 <tt>path-format</tt> 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 <tt>[[path]]</tt>. | ||
+ | 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 | ||
+ | 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]]. | ||
− | + | <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 --> |
Latest revision as of 19:54, 10 July 2008
Contents |
[edit] 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.
See the main page for a description of all available configuration settings.
[edit] Examples
<access-log path="logs/access.log" format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"' rollover-period="1W"/>
<access-log path="logs/access.log" format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"' rollover-size="1mb"/>
[edit] 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.
[edit] 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'/> ...
[edit] 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.
[edit] 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>
[edit] 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.
[edit] 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> ...
[edit] 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"/>
[edit] 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.
[edit] 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"/>