activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From semog <e.se...@gmail.com>
Subject Re: Any implementations of ITrace available in Apache.NMS
Date Thu, 20 Nov 2008 00:23:23 GMT

Here's a simple tracer implementation that will connect NMS to log4net.

In your client code, add the following line before making any NMS calls:

	Apache.NMS.Tracer.Trace = new MyTrace();

Here's the implementation of MyTrace:

// Configure log4net using the .config file
[assembly: log4net.Config.XmlConfigurator(Watch = true)]

public class MyTrace : Apache.NMS.ITrace
{
	internal static readonly log4net.ILog log;
	static MyTrace()
	{
		try
		{
			log = log4net.LogManager.GetLogger(typeof(MyTrace));
		}
		catch
		{
		}
	}

	#region ITrace Members
	public void Debug(string message)
	{
		log.Debug(message);
	}

	public void Error(string message)
	{
		log.Error(message);
	}

	public void Fatal(object message)
	{
		log.Fatal(message);
	}

	public void Info(string message)
	{
		log.Info(message);
	}

	public void Warn(string message)
	{
		log.Warn(message);
	}

	public bool IsDebugEnabled
	{
		get { return log.IsDebugEnabled; }
	}

	public bool IsErrorEnabled
	{
		get { return log.IsErrorEnabled; }
	}

	public bool IsFatalEnabled
	{
		get { return log.IsFatalEnabled; }
	}

	public bool IsInfoEnabled
	{
		get { return log.IsInfoEnabled; }
	}

	public bool IsWarnEnabled
	{
		get { return log.IsWarnEnabled; }
	}

	#endregion
}


mkeenan wrote:
> 
> I'm still working on what I think is a thread issue in NMS.  I see there
> are Tracer statements in the code, but it doesn't look like there are any
> prepackaged providers of the ITrace interface.  It would be trivial to
> roll my own but I want to make sure that is the only option before I go
> down that road.
> 

-- 
View this message in context: http://www.nabble.com/Any-implementations-of-ITrace-available-in-Apache.NMS-tp20565265p20592436.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message