Trace Switches for the DynamicQueryEngine

Posts   
 
    
simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 25-Oct-2006 06:56:16   

Is there an easy way to set the Trace Level for a DQE other than using the app.config file method?

I am using Unit Testing so the App.Config is not accessible (unless I'm missing something).

Cheers Simon

PS For now, I have created a static constructor in DataAccessAdapter which forces the switch to be created and I can then set the level. Is there a better way than this?

    static DataAccessAdapter()
    {
        new DynamicQueryEngine();
    }
Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 25-Oct-2006 09:35:38   

The switch is automatically created inside the constructor of the DynamicQueryEngine.

Maybe you just need to set the Switch.Level property to one of the TraceLevel enum values.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 25-Oct-2006 09:57:31   

What unittest lib do you use? I use testdriven.net (and thus mbunit) and I use .config files. You've to name them as the tests dll. So if your tests are in mytests.dll, then your config file has to be mytests.dll.config.

Frans Bouma | Lead developer LLBLGen Pro
simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 25-Oct-2006 11:04:47   

Otis wrote:

What unittest lib do you use? I use testdriven.net (and thus mbunit) and I use .config files. You've to name them as the tests dll. So if your tests are in mytests.dll, then your config file has to be mytests.dll.config.

I'm using Resharper's built-in runner.

I can't get VS to automatically create a file named as you suggested (either by App.Config or manually creating a file of the correct name and specifying Content as the Build Action) but manually copying a file into the folder did the trick - thanks very much.

Cheers Simon

PS Walaa Thats what I was trying to do but since it is a static switch, it only gets created when DynamicQueryEngine is first used. My test project doesn't have a reference to SD.LLBLGen.Pro.DQE.SqlServer.NET11 (though in hindsight I could have added one) so I couldn't access it directly and creating a DataAccessAdapter doesn't create a DQE until a query is actually executed. (I did create a switch directly on DynamicQueryEngineBase and set the level but of course when my query actually ran, the DQE it replaced it anyway - spend a few headscratching minutes discovering that one!)

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 25-Oct-2006 11:59:49   

simmotech wrote:

Otis wrote:

What unittest lib do you use? I use testdriven.net (and thus mbunit) and I use .config files. You've to name them as the tests dll. So if your tests are in mytests.dll, then your config file has to be mytests.dll.config.

I'm using Resharper's built-in runner.

I can't get VS to automatically create a file named as you suggested (either by App.Config or manually creating a file of the correct name and specifying Content as the Build Action) but manually copying a file into the folder did the trick - thanks very much.

Hmmm, my 'other databases' unittest project solution uses an app.config with a dll project, but that works fine: I get a normal unittest.dll.config file in the bin\debug folder. (VS.NET 2005, I think in 2003 it might be different)

Thats what I was trying to do but since it is a static switch, it only gets created when DynamicQueryEngine is first used. My test project doesn't have a reference to SD.LLBLGen.Pro.DQE.SqlServer.NET11 (though in hindsight I could have added one) so I couldn't access it directly and creating a DataAccessAdapter doesn't create a DQE until a query is actually executed. (I did create a switch directly on DynamicQueryEngineBase and set the level but of course when my query actually ran, the DQE it replaced it anyway - spend a few headscratching minutes discovering that one!)

The switch you've to access is the static property DynamicQueryEngine.Switch.

If you do: DynamicQueryEngine.Switch.Level = TraceLevel.Verbose; you've set the trace level manually to 4. Though this indeed requires you to reference the DQE in your own project.

Frans Bouma | Lead developer LLBLGen Pro
simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 25-Oct-2006 12:48:47   

The switch you've to access is the static property DynamicQueryEngine.Switch.

If you do: DynamicQueryEngine.Switch.Level = TraceLevel.Verbose; you've set the trace level manually to 4. Though this indeed requires you to reference the DQE in your own project.

I know the line that creates the switch (the cctor in DynamicQueryEngine) is

DynamicQueryEngine.Switch = new TraceSwitch("SqlServerDQE", "Tracer for SqlServer Dynamic Query Engine");

but the field is actually inherited from DynamicQueryEngineBase.

Ironically I can access DynamicQueryEngineBase without an additional reference but it gets scrubbed by the above line on first use of DynamicQueryEngine.

Cheers Simon

PS Is it just me but now I'm running IE7, I can't add smileys or formatting within text - each time I apply it, it puts the smiley/sections at the end of the text.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 25-Oct-2006 13:54:57   

simmotech wrote:

The switch you've to access is the static property DynamicQueryEngine.Switch.

If you do: DynamicQueryEngine.Switch.Level = TraceLevel.Verbose; you've set the trace level manually to 4. Though this indeed requires you to reference the DQE in your own project.

I know the line that creates the switch (the cctor in DynamicQueryEngine) is

DynamicQueryEngine.Switch = new TraceSwitch("SqlServerDQE", "Tracer for SqlServer Dynamic Query Engine");

but the field is actually inherited from DynamicQueryEngineBase.

Ironically I can access DynamicQueryEngineBase without an additional reference but it gets scrubbed by the above line on first use of DynamicQueryEngine.

Yes that's indeed true.

PS Is it just me but now I'm running IE7, I can't add smileys or formatting within text - each time I apply it, it puts the smiley/sections at the end of the text.

It's I think a security fix MS has brought out recently. Working on v2.0 of this forum system, I saw this yesterday in IE6, so it's not an IE7 thingy. I'll look into this this week anyway so I hope it's easily fixed.

Frans Bouma | Lead developer LLBLGen Pro
JimHugh
User
Posts: 191
Joined: 16-Nov-2005
# Posted on: 25-Oct-2006 17:44:25   

For SQL Server, I use the following in code to set it.


if (DynamicQueryEngineBase.Switch == null)
{
// inits static constructor
   DataAccessAdapter.SetArithAbortFlag(true);
   DynamicQueryEngineBase.Switch.Level = TraceLevel.Verbose;
}

simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 26-Oct-2006 06:26:36   

JimHugh wrote:

For SQL Server, I use the following in code to set it.


if (DynamicQueryEngineBase.Switch == null)
{
// inits static constructor
   DataAccessAdapter.SetArithAbortFlag(true);
   DynamicQueryEngineBase.Switch.Level = TraceLevel.Verbose;
}

Perfect - thanks Jim.