PDA

View Full Version : Logging not working


dturkel
07-01-2007, 05:40 PM
Similar to other posts, logging does not seems to be configured or working properly.

I'm using the latest release candidate build, and the straight-out Commons logging with the ConsoleOutLoggerFactoryAdapter.

Unfortunately I always end up with the NoOp Logger. My assembly includes all of the CommonsLogging DLLs that came with the release, so no "mickey-mousing" with nightly builds or alternate versions.

I'm only trying to call the logger in my client code (not the service COM+ object).

What could I possibly be doing wrong?

App.config:


<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging"/>
</sectionGroup>
</sectionGroup>
</configSections>
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">

<!--
<object name="FeedPublishingStreamWorker" type="Publishing.Common.IPublishingStreamWorker, PublishingCoordinatorCommon">
</object>
-->
<object name="SamplePublishingStreamWorker" id="SamplePublishingStreamWorker" type="Spring.EnterpriseServices.ServicedComponentFactory , Spring.Services">
<property name="Name" value="MyApp.EnterpriseServices.FeedPublishingStreamWorke r"/>

<property name="Server" value="127.0.0.1"/>
</object>
</objects>
<common>
<logging>
<factoryAdapter type="Common.Logging.Simple.ConsoleOutLoggerFactoryAdapt er, Common.Logging">
<arg key="level" value="ALL" />
<arg key="showLogName" value="true" />
<arg key="showDataTime" value="true" />
<arg key="dateTimeFormat" value="yyyy/MM/dd HH:mm:ss:fff" />
</factoryAdapter>
</logging>
</common>

</spring>


Client code snippet:

public class SampleClient
{
public static ILog log = null;

public SampleClient()
{
if (log == null)
{
log = LogManager.GetLogger(this.GetType());
}
}
public static void Main(string [] args)
{
SampleClient client = new SampleClient();
client.DoWork();
}
public string DoWork()
{

log.Debug("hello world");
//Load the ApplicationContext
IApplicationContext ctx;

. . .
. . .

dturkel
07-01-2007, 05:53 PM
I updated my client code to make sure logging was called AFTER the application context was loaded, but it didn't make any difference:


public SampleClient()
{

}
public static void Main(string [] args)
{
SampleClient client = new SampleClient();
client.DoWork();
}
public string DoWork()
{


//Load the ApplicationContext
IApplicationContext ctx;
try
{
//ctx = GetApplicationContext()
ctx = ContextRegistry.GetContext();
ILog log = LogManager.GetLogger(this.GetType());
log.Debug("hello world");
IPublishingStreamWorker worker = (IPublishingStreamWorker)ctx.GetObject("SamplePublishingStreamWorker");

worker.ProcessDocument("xxx");
return ("xxx");
}