Logging

alextkachman edited this page Jun 21, 2011 · 4 revisions
Clone this wiki locally

Gretty does some basic logging using internal logging capabilities of Netty. All you need to do is something like

 org.jboss.netty.logging.InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory())

This must be done in the beginning of your application (before Gretty/Netty used)

Netty provides implementations for most popular logging frameworks. Default is JdkLoggerFactory

Another feature is ability to have basic performance information logged periodically. For that you can set GrettyServer.logStatistics property to true.

Logged statistics looks like below

Jun 21, 2011 9:44:39 AM org.mbte.gretty.httpserver.IoMonitor
INFO: Server Statistic:
   Open connections:    4
   Total connections:   6866

   Http requests:       1372.3255348930213 req/sec
   Total http requests: 6863

   Bytes In:            109.89325572385522 Kb/sec
   Bytes Out:           404.6698472805439 Kb/sec
   TotalBytesSent:      2072324
   TotalBytesReceived:  562766

   Heap Memory:         init = 0(0K) used = 37153744(36282K) committed = 85000192(83008K) max = 129957888(126912K)
   Non Heap Memory:     init = 24317952(23748K) used = 23903424(23343K) committed = 38797312(37888K) max = 138412032(135168K)
   System load:         1.60595703125