Ticket #449 (closed enhancement: fixed)

Opened 5 years ago

Last modified 4 years ago

VirtualJournal: Logging

Reported by: jsuttor Assigned to: jsuttor
Priority: critical Milestone:
Component: ambra Version: 0.8
Keywords: plosone, virtualjournal, logging Cc:
Blocking: Blocked By:

Description

log messages should be in a per virtual journal log file.

  • it may be possible to prefix log entries with virtual journal name
  • fall-back is single intermixed log

Dependency Graph

Change History

07/14/07 20:46:17 changed by amit

I cannot seem to be able to find a way to do this via threads. There is a fairly clean way that will be better for the long term, but unfortunately I suspect not doable within 0.8 timeframe. This way will infolve replacing the default LogFactory? implementation of the commons logging package. Commons logging allows for this. Roughly the way this should work is each virtual journal be able to specify its own log4j.xml and the our replacement LogFactory? provides the switch. Any other ideas?

07/17/07 02:35:47 changed by ronald

How about just starting with using log4j's NDC or MDC stuff? Yes, it means one dependency on log4j in one class, and no, this doesn't split the logs into multiple files, but it does allow you to add the name of the virtual-journal to all log entries.

07/17/07 09:41:52 changed by amit

Of course. If we bypass using Commons Logging and make an assumption on the underlying logging package it gives us quite a few more options.

07/18/07 23:44:53 changed by amit

  • owner changed from amit to jsuttor.

Looked at Ronald's idea on NDC/MDC. It does look fairly simple. Here is some example code taken from http://www.vipan.com/htdocs/log4jhelp.html:

import org.apache.log4j.*;

public class TestNDC {

  // !Make sure log4j.properties file exists in classpath

  static Category cat = Category.getInstance(TestNDC.class.getName());

  public static void main(String[] args) {

    // Nested Diagnostic Configurator to identify the client for
    // multithreaded client request processors such as servlets, if needed
    NDC.push("Client #45890");

    cat.info("Testing Nested Diagnostic Context (NDC).");
    cat.info("Make sure %x is in layout pattern!");
    cat.info("Client #45890 should appear in this log message.");

    switchNDC();

    cat.info("Finished.");
  }

  static void switchNDC() {
    NDC.push("Client #99999");
    cat.debug("Client #99999 should appear nested in this log message.");
    NDC.pop();
  }

}

So the virtual journal can push the journal name at the switch for now as we are using log4j.

07/31/07 13:56:53 changed by jsuttor

  • status changed from new to closed.
  • resolution set to fixed.

fixed in r3305.

07/16/08 11:00:34 changed by

  • milestone deleted.

Milestone 0.8 deleted