473,399 Members | 2,278 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,399 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 3717
"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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.