473,786 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to configure in my app.config a TextWriterTrace Listener to use System.Console. Out ?

hello

I'd like to add a listener in the app.config of my application, something like
<add name="myListene r" type="System.Di agnostics.TextW riterTraceListe ner"/>
I can use initializeData= "mylog.txt" to trace in a file but I 'd like to trace in
the console but I can't find how to do ... I can't see any samples of that in msdn
or elsewhere

thanks for your help
didier
Nov 16 '05 #1
1 6030
Didier Bolf <di*********@wa nadoo.fr> wrote:
I'd like to add a listener in the app.config of my application, something like
<add name="myListene r" type="System.Di agnostics.TextW riterTraceListe ner"/>
I can use initializeData= "mylog.txt" to trace in a file but I 'd like to trace in
the console but I can't find how to do ... I can't see any samples of that in msdn
or elsewhere


I don't know about the trace listener side of things, but it sounds
like you want to redirect the console, so use Console.SetOut to set the
output to your own custom TextWriter which then writes the output
however you want it to.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2

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

Similar topics

0
2779
by: Per Bergland | last post by:
After many woes, I finally managed to get a stack dump of my System Service (written in C#) that insists on crashing when launched at system boot time (see below on how to get this dump - I couldn't find any info on how to do this). Here's the stack trace from cordbg: Unhandled exception generated: (0x04719c94) <System.Runtime.Remoting.RemotingException> _className=<null> _exceptionMethod=<null>
0
3855
by: Ant Corrie | last post by:
I am at a loss as to why this is not working. I am trying to setup a TextWriterTraceListener in my application config file and then execute the app from the network. I get a security exception (listed below) even though I have StrongNamed my application and used the .NET Configuration Tool to create a Code Access Group in the Machine Policy that gives FullTrust to assemblies with the StrongName that I created. If you uncomment the code...
3
9511
by: Daniel Billingsley | last post by:
The documentation on this subject seems to give you 98% of what you need to know. From various sources, I have compiled an understanding that this should work: <configuration> <system.diagnostics> <switches> <add name="clientswitch" value="3" /> </switches> <trace autoflush="true" indentsize="0">
2
3694
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 from solution explorer. My config file is composed of the following, which is almost a verbatum cut & paste from MSDN help: --------------------------------------------------------------------------- <?xml version="1.0" encoding="utf-8" ?>...
0
1434
by: Pete W | last post by:
I have a console application for which I have atttemped to use TextWriterTraceListener. The app uses System.Diagnostic I want to trace or debug to Console and also to file. code in Main() includes: TextWriterTraceListener fw = new TextWriterTraceListener(myFile); TextWriterTraceListener sw = new TextWriterTraceListener(Console.Out); Trace.Listeners.Add(fw); Trace.Listeners.Add(sw);
4
15651
by: Jiho Han | last post by:
I have the following defined in web.config under <configuration> node: <system.diagnostics> <switches> <add name="MainSwitch" value="4"/> </switches>
3
2781
by: Shawn Melton | last post by:
I cannot get a clean compile if I add Trace configuration info into my web.config. This generates an error: <configuration> <system.diagnostics> <switches> <add name="MyTraceSwitch" value="4" /> </switches> <trace autoflush="false" indentsize="4"> <listeners>
3
8234
by: gslim | last post by:
I have created a trace listener and would like to give it a variable so that when it is installed on a machine I have no control over it can still find its logfile. Right now they are hardcoded as "C:\Inetpub\wwwroot\website\log1.txt" is there a way to insert something like "~/logfile.txt") blizzardice <code> <sharedListeners>
6
2908
by: Peted | last post by:
Hi, im wanting to store some custom text strings in the app.config file of a c# app, to be retreived and updated when the app runs. using c# 2005 express in my testing i am using the code bellow, and its almost idenictal to every web example i have found. They all suggest the values and file can be read from and updated. The code bellow runs, with no errors of
0
9491
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10357
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7510
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4063
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.