log
Resin can perform access logging, specify where JDK logging interface messages go, and redirect the stderr and stdout for your applications. 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 <log-handler> creates a destination for logs, sets a minimum logging level for the handler, and attaches the handler to a logging name. In addition to configuring custom handlers, <log-handler> has the most common configuration build-in: logging to a rotating file. Most of the configuration attributes are used for the rotating file and are shared with the other logging configuration.
element log-handler { archive-format? & class? & filter? & format? & formatter? & level? & mbean-name? & name & path? & path-format? & rollover-count? & rollover-period? & rollover-size? & timestamp? & use-parent-handlers? } The following example is a standard log handler writing to a rollover file. Because the handler's level is "all", the <logger> configuration will set the actual logging level. <web-app xmlns="http://caucho.com/ns/resin"> <log-handler name="" level="all" timestamp="[%Y/%m/%d %H:%M:%S.%s] {%{thread}} "/> <logger name="com.caucho" level="info"/> </web-app> The <log name='' level='all' path='stderr:' timestamp="[%H:%M:%S.%s]" format=" ${log.level} ${log.loggerName} ${log.message}"/>
You can also use the Environment EL variables in your format string: <host ...> <web-app> <log name='' level='all' path='log/debug.log' timestamp="[%H:%M:%S.%s]" format=" [${app.contextPath}] ${log.message}"/> ... </web-app> ... </host> [14:55:10.189] [/foo] `null' returning JNDI java: model for EnvironmentClassLoader[web-app:http://localhost:8080/foo] [14:55:10.189] [/foo] JNDI lookup `java:comp/env/caucho/auth' exception javax.naming.NameNotFoundException: java:comp/env/caucho/auth [14:55:10.199] [/foo] Application[http://localhost:8080/foo] starting The fmt.sprintf() function can space pad the values and make the results look a little nicer: <log name='' level='all' path='stderr:' timestamp="[%H:%M:%S.%s]" format=" ${fmt.sprintf('%-7s %45s %s',log.level,log.loggerName,log.message)}"/> [14:28:08.137] INFO com.caucho.vfs.QJniServerSocket Loaded Socket JNI library. [14:28:08.137] INFO com.caucho.server.port.Port http listening to *:8080 [14:28:08.137] INFO com.caucho.server.resin.ServletServer ServletServer[] starting [14:28:08.307] INFO com.caucho.server.port.Port hmux listening to localhost:6802 [14:28:08.437] INFO com.caucho.server.host.Host Host[] starting fmt.sprintf() and fmt.timestamp() can be used to produce CSV files: <log name='' level='all' path='log/debug.csv' timestamp="" format="${fmt.sprintf('%vs,%d,%d,%vs,%vs',fmt.timestamp('%Y-%m-%d %H:%M:%S.%s'), log.threadID, log.level.intLevel(), log.loggerName, log.message)}"/> "2003-11-17 14:46:14.529",10,800,"com.caucho.vfs.QJniServerSocket", "Loaded Socket JNI library." "2003-11-17 14:46:14.549",10,800,"com.caucho.server.port.Port", "http listening to *:8080" "2003-11-17 14:46:14.549",10,800,"com.caucho.server.resin.ServletServer", "ServletServer[] starting" "2003-11-17 14:46:14.719",10,800,"com.caucho.server.port.Port", "hmux listening to localhost:6802" "2003-11-17 14:46:14.850",10,800,"com.caucho.server.host.Host", "Host[] starting" "2003-11-17 14:46:15.100",10,800,"com.caucho.server.webapp.Application", "Application[http://localhost:8080/freelistbm] starting"
|