Application Server: Health System:Examining Log Database

From Resin 4.0 Wiki

Revision as of 18:56, 9 December 2013 by Alex (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Heart-48.pngCookbook-48.png

Listing entries in log database

Resin's log database is an internal file located in $RESIN_ROOT/resin-data/{server-id}/log/*.db. File log_data.db in that location contains the actual database entries. By default, it should keep up to 14 days of entries. The reaper runs every day and cleans up entries older than the configurable keep period (14 days).

When the log file grows big and you don't know what's in it there are a couple of things you can do. First examine the resin-admin/summary page for that server. Logs tab will show up to 40 last messages.

Second – run a PDF report and examine the log messages section.

Third - copy the below code into a log.jsp page in your root application and run it. I'll display up to two days of messages. If the page hangs, it probably means you have too many messages in the database and need to change DAYS parameter by setting it to '1'

The code below was verified with Resin-Pro-4.0.37

<%@ page import="java.util.logging.*, 
                java.util.*, 
                javax.inject.*, 
                com.caucho.admin.*, 
                com.caucho.env.log.*, 
                com.caucho.management.server.*, 
                com.caucho.server.resin.*" 
                contentType="text/plain"%>
<%!
  @Inject LogSystem log;
  int DAYS = 2; 
%>
 
<%
  long now = System.currentTimeMillis();
  Resin resin = Resin.getCurrent();
  int id = resin.getSelfServer().getIndex();
  String extId = (id < 10 ? "0" + id : "" + id);

  LogMessage[] messages 
    = log.findMessages(extId + "|Resin|Log", null, (now - (1000 * 60 * 60 * 24 * DAYS)), now);

  for (int i = 0; i < messages.length; i++) {
    LogMessage message = messages[i];
    out.println(message.getName() + "[" + message.getLevel() + "][" + new Date(message.getTimestamp()) + "]: " +  message.getMessage());
  }
%>
Personal tools
TOOLBOX
LANGUAGES