⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 config-log.xtp

📁 RESIN 3.2 最新源码
💻 XTP
📖 第 1 页 / 共 3 页
字号:
<document><header>  <product>resin</product>  <title>Log</title>  <description>  <p>Resin can perform access logging, specify where JDK  logging interface messages go, and redirect the stderr and  stdout for your applications.</p>  </description></header><body><localtoc/><s1 title="java.util.logging"><s2 title="Logger: Application logging"><p>You can take advantage of the JDK's logging facility to addlogging to your application.  Choosing a good logging name and levelsare important for troubleshooting and debugging your code.  Loggingto much can be almost as confusing as logging too little.</p><p>The logging name should be the full class name of the class you'reinstrumenting.  Although other schemes are possible, the class nameis more maintainable.</p><p>The logging level should be consistent across your application.  For Resin,we use the following level conventions:</p><example title="Example: logging at finer">import java.util.logging.Logger;import java.util.logging.Level;public class Foo {  private static final Logger log    = Logger.getLogger(Foo.class.getName());  ...  void doFoo(String bar)  {    // check for log level if your logging call does anything more    // than pass parameters    if (log.isLoggable(Level.FINER))        log.finer(this + "doFoo(" + bar + ")");    ...    log.info(...);    try {        ...    } catch (ExpectedException ex) {      log.log(Level.FINEST, "expected exception", ex);    }  }  ...}</example></s2><s2 title="Log names"><p>The JDK logging api uses a hierarchical naming scheme.  Typically the nameis aligned with a java class name.  When you specify a name, all loggingrequests that use a name that starts with the name you have specified arematched.  For example: <code>&lt;logger name="example.hogwarts" ...&gt;</code>matches a logging request for both "example.hogwarts.System" and"example.hogwarts.gryffindor.System"</p><p>Resin's logging is based on Resin's source class names.  The following areuseful logs.</p><deftable title="Resin log names"><tr>  <th>name</th>  <th>Meaning</th></tr><tr>  <td>""</td>  <td>Debug everything</td></tr><tr>  <td>com.caucho.amber</td>  <td>Amber (JPA) handling</td></tr><tr>  <td>com.caucho.ejb</td>  <td>EJB handling</td></tr><tr>  <td>com.caucho.jsp</td>  <td>Debug jsp</td></tr><tr>  <td>com.caucho.java</td>  <td>Java compilation</td></tr><tr>  <td>com.caucho.server.port</td>  <td>TCP port debugging and threading</td></tr><tr>  <td>com.caucho.server.port.AcceptPool</td>  <td>port thread creation</td></tr><tr>  <td>com.caucho.server.http</td>  <td>HTTP-related debugging</td></tr><tr>  <td>com.caucho.server.webapp</td>  <td>web-app related debugging</td></tr><tr>  <td>com.caucho.server.cache</td>  <td>Cache related debugging</td></tr><tr>  <td>com.caucho.sql</td>  <td>Database pooling</td></tr><tr>  <td>com.caucho.transaction</td>  <td>Transaction handling</td></tr></deftable></s2> <!-- Log names --><s2 title="Log levels"><p>The <var>level</var> for log tags matches the levels in the JDK <a href="javadoc|java.util.logging.Level|"/>.</p><deftable title="Logging Level values"><tr>  <th>Name</th>  <th>API</th>  <th>Suggested Use</th></tr><tr>  <td>off</td>  <td>&#160;</td>  <td>turn off logging</td></tr><tr>  <td>severe</td>  <td>log.severe("...")</td>  <td>a major failure which prevents normal program execution,e.g. a web-app failing to start or a server restart</td></tr><tr> <td>warning</td>  <td>log.warning("...")</td>  <td>a serious issue, likely causing incorrect behavior, like a500 response code to a browser</td></tr><tr>  <td>info</td>  <td>log.info("...")</td>  <td>major lifecycle events, like a web-app starting</td></tr><tr>  <td>config</td>  <td>log.config("...")</td>  <td>detailed configuration logging</td></tr><tr>  <td>fine</td>  <td>log.fine("...")</td>  <td>debugging at an administrator level, i.e. for someone not familiar withthe source code being debugged</td></tr><tr>  <td>finer</td>  <td>log.finer("...")</td>  <td>detailed debugging for a developer of the code being debugged</td></tr><tr>  <td>finest</td>  <td>log.finest("...")</td>  <td>events not normally debugged, e.g. expected exceptions logged toavoid completely swallowing, or Hessian or XML protocol parsing</td></tr><tr>  <td>all</td>  <td>&#160;</td>  <td>all messages should be logged</td></tr></deftable></s2><s2 title="&lt;log-handler>" type="defun"><parents>resin, server, host-default, host, web-app-default, web-app</parents>   <p>Configure a log handler for the JDK java.util.logging.* API.java.util.logging has two steps: configure a set of log handlers,and configure the levels for each logger.  The &lt;log-handler> createsa destination for logs, sets a minimum logging level for the handler,and attaches the handler to a logging name.</p><p>In addition to configuring custom handlers, &lt;log-handler> has themost common configuration build-in: logging to a rotating file.  Most of theconfiguration attributes are used for the rotating file and are sharedwith the other logging configuration.</p><deftable-childtags title="&lt;log-handler> values"><tr>  <th>Attribute</th>  <th>Description</th>  <th>Default</th></tr><tr>  <td>archive-format</td>  <td>the format for the archive filename when a rollover occurs,        see <a href="#rollover">Rollovers</a>.    </td>  <td>see below</td></tr><tr>  <td>class</td>  <td>configures a custom Handler class</td>  <td></td></tr><tr>  <td>formatter</td>  <td>Configures a custom java.util.logging.Formatter to formatthe output.</td>  <td></td></tr><tr>  <td>init</td>  <td>IoC-style initialization configuration for the formatter.</td>  <td></td></tr><tr>  <td>level</td>  <td>The <a href="#Log-Levels">log level</a> for the handler.  Typically,the handler's level will be finer than the logger's level</td>  <td>info</td></tr><tr>  <td>mbean-name</td>  <td>an mbean name, see <a href="#mbean">MBean control</a>.</td>  <td>no mbean name, no mbean registration</td></tr><tr>  <td>name</td>  <td>A hierarchical name, typically aligned with the Java packaging names.The handler will be registered with the Logger with the matching name.</td>  <td>match all names</td></tr><tr>  <td>path</td>  <td>Output path for the log messages, see        <a href="#path">"Log Paths"</a>    </td>  <td>required</td></tr><tr>  <td>path-format</td>  <td>Selects a format for generating path names.  The syntax is the same as for archive-format</td>  <td>optional</td></tr><tr>  <td>timestamp</td>  <td>a timestamp <a href="#timestamp">format string</a>         to use at the beginning of each log line.    </td>  <td>"[%Y/%m/%d %H:%M:%S.%s] "</td></tr><tr>  <td>rollover-count</td>  <td>maximum number of rollover files before the oldest ones get overwritten.        See <a href="#rollover">Rollovers</a>.     </td>  <td>none</td></tr><tr>  <td>rollover-cron</td>  <td>cron-style specification on rollover times.</td>  <td>none</td></tr><tr>  <td>rollover-period</td>  <td>how often to rollover the log.  Specify in days (15D), weeks (2W),         months (1M), or hours (1h). See <a href="#rollover">Rollovers</a>.     </td>  <td>none</td></tr><tr>  <td>rollover-size</td>  <td>maximum size of the file before a rollover occurs, in bytes (50000),         kb (128kb), or megabytes (10mb).          See <a href="#rollover">Rollovers</a>.    </td>  <td>1mb</td></tr><tr>  <td>uri</td>  <td>configures a symbolic alias for the handler's class.  The handler implementer will register the schema</td>  <td></td></tr></deftable-childtags><def title="&lt;log-handler> schema">element log-handler {  archive-format?  &amp; class?  &amp; filter?  &amp; format?  &amp; formatter?  &amp; init?  &amp; level?  &amp; mbean-name?  &amp; name  &amp; path?  &amp; path-format?  &amp; rollover-count?  &amp; rollover-period?  &amp; rollover-size?  &amp; timestamp?  &amp; uri?  &amp; use-parent-handlers?}</def><p>The following example sends warning messages to a JMS queue.  The<code>uri="jms:"</code> is an aliasfor <code>com.caucho.log.handler.JmsHandler</code>.  The<code>uri="timestamp:"</code> is a formatter aliasfor <code>com.caucho.log.formatter.TimestampFormatter</code></p><example title="Example: logging to a JMS queue">&lt;web-app xmlns="http://caucho.com/ns/resin">  &lt;jms-queue name="myQueue" uri="memory:"/>  &lt;log-handler name="qa.test" level="warning" uri="jms:">    &lt;init target="${myQueue}"/>    &lt;formatter uri="timestamp:"/>  &lt;/log-handler>&lt;/web-app></example><p>The following example is a standard log handler writing to a rolloverfile.  Because the handler's level is "all", the &lt;logger> configurationwill set the actual logging level.</p><example title="Example: logging to a rollover file">&lt;web-app xmlns="http://caucho.com/ns/resin">  &lt;jms-queue name="myQueue" uri="memory:"/>  &lt;log-handler name="" level="all"       timestamp="[%Y/%m/%d %H:%M:%S.%s] {%{thread}} "/>  &lt;logger name="com.caucho" level="info"/>&lt;/web-app></example></s2><s2 title="&lt;log>" type="defun"><parents>resin, server, host-default, host, web-app-default, web-app</parents>   <p>Configure the amount and destination of debug logging for the JDKjava.util.logging.* API.</p><deftable-childtags title="&lt;log> values"><tr>  <th>Attribute</th>  <th>Description</th>  <th>Default</th></tr><tr>  <td>name</td>  <td>A hierarchical name, typically aligned with the Java packaging names</td>  <td>match all names</td></tr><tr>  <td>level</td>  <td>The <a href="#Log-Levels">log level</a></td>  <td>info</td></tr><tr>  <td>path</td>  <td>Output path for the log messages, see        <a href="#path">"Log Paths"</a>    </td>  <td>required</td></tr><tr>  <td>path-format</td>  <td>Selects a format for generating path names.  The syntax is the same as for archive-format</td>  <td>optional</td></tr><tr>  <td>timestamp</td>  <td>a timestamp <a href="#timestamp">format string</a>         to use at the beginning of each log line.    </td>  <td>"[%Y/%m/%d %H:%M:%S.%s] "</td></tr><tr>  <td>format</td>  <td>a <a href="#Format-String">format string</a> to control the         output of each log message. Since Resin 3.0.5.    </td>  <td>${log.message}</td></tr><tr>  <td>rollover-count</td>  <td>maximum number of rollover files before the oldest ones get overwritten.        See <a href="#rollover">Rollovers</a>.     </td>  <td>none</td></tr><tr>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -