473,327 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Custom Trace Listener & .exe.config

Hi!

I have created a custom trace Listener class, called "DBTraceListener"

it works fine when i add it manually in code :
(eg. Trace.listeners.add(new DBTraceListener("myDBListener",
TraceLevel.Verbose, getDBConnection) )

What I'm trying to achieve now is to add this listener via the
MyApplication.exe.config file

Here is my configuration file:

<configuration>
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<remove name ="Default"/>
<add name="myDBListener" type="DBTraceListener"/>
</listeners>
</trace>
</system.diagnostics>
</configuration>

Unfortunately, when im executing the application the DefaultTraceListener is
removed BUT my DBTraceListener is not added!!! and I dont get any exceptions!
So what is going on?

Thanks in advance!
G.
Jul 21 '05 #1
8 3714
"Geopsaros" <Ge*******@discussions.microsoft.com> wrote in message
news:64**********************************@microsof t.com...
Hi!

I have created a custom trace Listener class, called "DBTraceListener"

it works fine when i add it manually in code :
(eg. Trace.listeners.add(new DBTraceListener("myDBListener",
TraceLevel.Verbose, getDBConnection) )

What I'm trying to achieve now is to add this listener via the
MyApplication.exe.config file

Here is my configuration file:

<configuration>
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<remove name ="Default"/>
<add name="myDBListener" type="DBTraceListener"/>
</listeners>
</trace>
</system.diagnostics>
</configuration>

Unfortunately, when im executing the application the DefaultTraceListener
is
removed BUT my DBTraceListener is not added!!! and I dont get any
exceptions!
So what is going on?


From the above, it looks like your listener requires three parameters in its
constructor. How would those parameters be passed to it by the config file?

I'm surprised you don't get an exception, though. Try this experiment:
Change the "type" to "DBTraceListenerX" and see if you get an exception.

John Saunders
Jul 21 '05 #2
John, i have tried it! No exceptions, no errors ...nothing
I have also tried type="" and No type attribute at all!

As far as the constructor is concerced, There are 2 constructors,
one without parameters and one with 3 parameters.

The DBTraceListener works without problems when added programmatically with
either of those....
"John Saunders" wrote:
"Geopsaros" <Ge*******@discussions.microsoft.com> wrote in message
news:64**********************************@microsof t.com...
Hi!

I have created a custom trace Listener class, called "DBTraceListener"

it works fine when i add it manually in code :
(eg. Trace.listeners.add(new DBTraceListener("myDBListener",
TraceLevel.Verbose, getDBConnection) )

What I'm trying to achieve now is to add this listener via the
MyApplication.exe.config file

Here is my configuration file:

<configuration>
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<remove name ="Default"/>
<add name="myDBListener" type="DBTraceListener"/>
</listeners>
</trace>
</system.diagnostics>
</configuration>

Unfortunately, when im executing the application the DefaultTraceListener
is
removed BUT my DBTraceListener is not added!!! and I dont get any
exceptions!
So what is going on?


From the above, it looks like your listener requires three parameters in its
constructor. How would those parameters be passed to it by the config file?

I'm surprised you don't get an exception, though. Try this experiment:
Change the "type" to "DBTraceListenerX" and see if you get an exception.

John Saunders

Jul 21 '05 #3
Below is an extract of what I used:

In fact, you have to fully identify your listener in the type attribute.

type="<fully qualified class (assembly.className)>, <dll name that holds the
class>"

By the way, the default CTOR gets called when pluggin from the config file.

Hope this help,
José
Snippet:
--------
<system.diagnostics>
<switches>
<!-- Global switch used by ttc programs. This is the master switch.
Any severity values
above this level will be blocked and not passed to the registered
ttc listeners.
Valid values are: 0:none, 1:error, 2:warning, 3: info,
-->
<add name="ttcGlobalSwitch" value="4" />
</switches>
<trace>
<listeners>
<remove name="Default" />
<add name="ttcTextListener"
type="Company.Base.ttcTextTraceListener,Company.Ba se"/>
<add name="ttcEventLogListener"
type="Company.Base.ttcEventLogTraceListener,Compan y.Base"/>
<add name="ttcMailListener"
type="Company.Base.ttcMailTraceListener,Company.Ba se"/>
</listeners>
</trace>
</system.diagnostics>

"Geopsaros" <Ge*******@discussions.microsoft.com> a écrit dans le message de
news:64**********************************@microsof t.com...
Hi!

I have created a custom trace Listener class, called "DBTraceListener"

it works fine when i add it manually in code :
(eg. Trace.listeners.add(new DBTraceListener("myDBListener",
TraceLevel.Verbose, getDBConnection) )

What I'm trying to achieve now is to add this listener via the
MyApplication.exe.config file

Here is my configuration file:

<configuration>
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<remove name ="Default"/>
<add name="myDBListener" type="DBTraceListener"/>
</listeners>
</trace>
</system.diagnostics>
</configuration>

Unfortunately, when im executing the application the DefaultTraceListener is removed BUT my DBTraceListener is not added!!! and I dont get any exceptions! So what is going on?

Thanks in advance!
G.

Jul 21 '05 #4
I'll give some more details because i still cant make it work :(

My custom tracelistener is a class called "DBTraceListener"
This class is inside a class called "DBFacade", which is declared
in a project called "DBAcces"

e.g Class DBFacade
......
Class DBTraceListener
......
End class 'DBTraceListener
End class 'DBFacade
My Solution's starting project is called "ForeignOfficeV2" and its a Windows
Application.

There arent any namespaces declared! Hence, the listener add line should be
: <add name="DBListenerFromConfigFile"
type="DBAcces.DBFacade.DBTraceListener,DBAcces"/>
Am I right? In case I am not, i'm also wondering why I dont get any
exceptions or error messages?

Any help is really appreciated!
"José Joye" wrote:
Below is an extract of what I used:

In fact, you have to fully identify your listener in the type attribute.

type="<fully qualified class (assembly.className)>, <dll name that holds the
class>"

By the way, the default CTOR gets called when pluggin from the config file.

Hope this help,
José
Snippet:
--------
<system.diagnostics>
<switches>
<!-- Global switch used by ttc programs. This is the master switch.
Any severity values
above this level will be blocked and not passed to the registered
ttc listeners.
Valid values are: 0:none, 1:error, 2:warning, 3: info,
-->
<add name="ttcGlobalSwitch" value="4" />
</switches>
<trace>
<listeners>
<remove name="Default" />
<add name="ttcTextListener"
type="Company.Base.ttcTextTraceListener,Company.Ba se"/>
<add name="ttcEventLogListener"
type="Company.Base.ttcEventLogTraceListener,Compan y.Base"/>
<add name="ttcMailListener"
type="Company.Base.ttcMailTraceListener,Company.Ba se"/>
</listeners>
</trace>
</system.diagnostics>

"Geopsaros" <Ge*******@discussions.microsoft.com> a écrit dans le message de
news:64**********************************@microsof t.com...
Hi!

I have created a custom trace Listener class, called "DBTraceListener"

it works fine when i add it manually in code :
(eg. Trace.listeners.add(new DBTraceListener("myDBListener",
TraceLevel.Verbose, getDBConnection) )

What I'm trying to achieve now is to add this listener via the
MyApplication.exe.config file

Here is my configuration file:

<configuration>
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<remove name ="Default"/>
<add name="myDBListener" type="DBTraceListener"/>
</listeners>
</trace>
</system.diagnostics>
</configuration>

Unfortunately, when im executing the application the DefaultTraceListener

is
removed BUT my DBTraceListener is not added!!! and I dont get any

exceptions!
So what is going on?

Thanks in advance!
G.


Jul 21 '05 #5
"Geopsaros" <Ge*******@discussions.microsoft.com> wrote in message
news:5F**********************************@microsof t.com...
I'll give some more details because i still cant make it work :(

My custom tracelistener is a class called "DBTraceListener"
This class is inside a class called "DBFacade", which is declared
in a project called "DBAcces"


What happens when you "don't do that"? Pull the listener out to top level
and see what happens.

Afterwards, take a look at System.Type.AssemblyQualifiedName.

John Saunders
Jul 21 '05 #6
I moved the "DBTraceListener" class in a separate file in the "DBAcces"
project and YES it finally Worked!!!!

the add listener line is now as follows:
type="DBAcces.DBTraceListener,DBAcces"/>

thanks a lot John!

I hope someone can answer why a listener cant be added
when its class is declared inside another class, or how this can be done?

"John Saunders" wrote:
"Geopsaros" <Ge*******@discussions.microsoft.com> wrote in message
news:5F**********************************@microsof t.com...
I'll give some more details because i still cant make it work :(

My custom tracelistener is a class called "DBTraceListener"
This class is inside a class called "DBFacade", which is declared
in a project called "DBAcces"


What happens when you "don't do that"? Pull the listener out to top level
and see what happens.

Afterwards, take a look at System.Type.AssemblyQualifiedName.

John Saunders

Jul 21 '05 #7
If you have not defined any namespace within the DBAccess then you should
(at least I guess...) have the following:
: <add name="DBListenerFromConfigFile"
type="DBFacade.DBTraceListener,DBAcces"/>
I assume that your DBTraceListener class derives from
System.Diagnostics.TraceListener and your DBAccess project generates a
DBAccess.dll file which is located in the same directory as your
xyz.exe.config file.

Hope this help,
-José

"Geopsaros" <Ge*******@discussions.microsoft.com> wrote in message
news:5F**********************************@microsof t.com... I'll give some more details because i still cant make it work :(

My custom tracelistener is a class called "DBTraceListener"
This class is inside a class called "DBFacade", which is declared
in a project called "DBAcces"

e.g Class DBFacade
......
Class DBTraceListener
......
End class 'DBTraceListener
End class 'DBFacade
My Solution's starting project is called "ForeignOfficeV2" and its a Windows Application.

There arent any namespaces declared! Hence, the listener add line should be : <add name="DBListenerFromConfigFile"
type="DBAcces.DBFacade.DBTraceListener,DBAcces"/>
Am I right? In case I am not, i'm also wondering why I dont get any
exceptions or error messages?

Any help is really appreciated!
"José Joye" wrote:
Below is an extract of what I used:

In fact, you have to fully identify your listener in the type attribute.

type="<fully qualified class (assembly.className)>, <dll name that holds the class>"

By the way, the default CTOR gets called when pluggin from the config file.
Hope this help,
José
Snippet:
--------
<system.diagnostics>
<switches>
<!-- Global switch used by ttc programs. This is the master switch. Any severity values
above this level will be blocked and not passed to the registered ttc listeners.
Valid values are: 0:none, 1:error, 2:warning, 3: info,
-->
<add name="ttcGlobalSwitch" value="4" />
</switches>
<trace>
<listeners>
<remove name="Default" />
<add name="ttcTextListener"
type="Company.Base.ttcTextTraceListener,Company.Ba se"/>
<add name="ttcEventLogListener"
type="Company.Base.ttcEventLogTraceListener,Compan y.Base"/>
<add name="ttcMailListener"
type="Company.Base.ttcMailTraceListener,Company.Ba se"/>
</listeners>
</trace>
</system.diagnostics>

"Geopsaros" <Ge*******@discussions.microsoft.com> a écrit dans le message de news:64**********************************@microsof t.com...
Hi!

I have created a custom trace Listener class, called "DBTraceListener"

it works fine when i add it manually in code :
(eg. Trace.listeners.add(new DBTraceListener("myDBListener",
TraceLevel.Verbose, getDBConnection) )

What I'm trying to achieve now is to add this listener via the
MyApplication.exe.config file

Here is my configuration file:

<configuration>
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<remove name ="Default"/>
<add name="myDBListener" type="DBTraceListener"/>
</listeners>
</trace>
</system.diagnostics>
</configuration>

Unfortunately, when im executing the application the
DefaultTraceListener is
removed BUT my DBTraceListener is not added!!! and I dont get any

exceptions!
So what is going on?

Thanks in advance!
G.


Jul 21 '05 #8
"Geopsaros" <Ge*******@discussions.microsoft.com> wrote in message
news:6A**********************************@microsof t.com...
I moved the "DBTraceListener" class in a separate file in the "DBAcces"
project and YES it finally Worked!!!!

the add listener line is now as follows:
type="DBAcces.DBTraceListener,DBAcces"/>

thanks a lot John!

I hope someone can answer why a listener cant be added
when its class is declared inside another class, or how this can be done?
Afterwards, take a look at System.Type.AssemblyQualifiedName.


John

"John Saunders" wrote:
"Geopsaros" <Ge*******@discussions.microsoft.com> wrote in message
news:5F**********************************@microsof t.com...
> I'll give some more details because i still cant make it work :(
>
> My custom tracelistener is a class called "DBTraceListener"
> This class is inside a class called "DBFacade", which is declared
> in a project called "DBAcces"


What happens when you "don't do that"? Pull the listener out to top level
and see what happens.

Afterwards, take a look at System.Type.AssemblyQualifiedName.

John Saunders

Jul 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Kevin Pease | last post by:
Hi, I've written a custom trace listener and am currently trying to test it by registering it in the app config of another app. Every time the app runs I get a message saying "Couldn't find...
2
by: Richard | last post by:
Hi, I'm having trouble setting up a config file based trace switch & listener. I added an application config file to my console based C# program using the "Add New Application Config File" button...
3
by: Schorschi | last post by:
Ok, can someone point out to me why the following code does not work? In compiles, no errors, but MemoryStream never seems to receive any data? Dim theMemory As MemoryStream, _ theListener As...
2
by: Jason L James | last post by:
Hi all, can anyone help me with some tracing I am trying to do in my application. I have a configuration file containing the XML as detailed below: <?xml version="1.0" encoding="utf-8" ?>...
8
by: Geopsaros | last post by:
Hi! I have created a custom trace Listener class, called "DBTraceListener" it works fine when i add it manually in code : (eg. Trace.listeners.add(new DBTraceListener("myDBListener",...
0
by: Eniac | last post by:
Hello, I've started using Enterprise Library 2.0 recently and I've encountered a problem that seems to be ... well... undocumented :) Basically, when I set a Trace Listener (formatted event...
1
by: Tris | last post by:
I've got a web service running, and i'm trying to build tracing into it that is outputted to a file. Unfortunately, i can't find a way of enabling TRACE token, and it just seems to skip over all...
1
by: herbert | last post by:
I am using a TraceSource object configured via app.config. In order to delete the old file before starting the new trace, I need to obtain the filename from the listener. What am I doing wrong in...
0
by: boldtbanan | last post by:
I've created a custom trace listener which I'd like to initialize in the web.config file of my application. I noticed that I can use the initializeData attribute to pass a string to the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.