Newbie & app logging

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all

Since I'm just starting with C#, maybe I shouldn't be trying to apply MFC; i.e. 'extern'. What I want to do
is write an C# app that I can take from a developmental PC, put it on a production PC and run it. If any problem
occurr, I would like to look at a log of the app and see what the last thing was that happened.
Now if in my C# app I add a class for communication, a class for printing, a class for handling disk I/O
and maybe a class for emailing, I would like each class to be able to write to the common app log. From th
reply to my last post, it looked like I should be considering 'Singletons'. But, where in the app's code do I put thi
'Singleton' so that each class knows of it, how do I tell each class the 'Singleton' exists, and how does each class use it
as for instance to open the log, write an entry, and close the log
Most of what I've read describes the 'Singleton' itself and it's advantages/disadvantages, but I haven'
found anything that says 'put it here so it will be seen by all', 'do this to use the singleton'. The same thin
seems to be true of 'static'. Most of the documentation seems to say what 'statics' are, why they are,etc
That's fine, but as a newbie, I'm looking for something that tells me
"if you want to use a 'static' and want it to be seen by the app, and any class in the app, put it here
declare it like this, and use it like this"
For some reason, I may be 'looking' at the correct documentation, tutorials, but I'm just not 'seeing' the informatio
that's there

Any help, samples,snippets,etc. appreciated..

TIA

Ray K
 
Have you looked at System.Diagnostics.Trace? This sounds like it'll do what
you want, and it's very flexible.
-mike
MVP

raykos said:
Hello all,

Since I'm just starting with C#, maybe I shouldn't be trying to apply
MFC; i.e. 'extern'. What I want to do,
is write an C# app that I can take from a developmental PC, put it on a
production PC and run it. If any problems
occurr, I would like to look at a log of the app and see what the last thing was that happened.
Now if in my C# app I add a class for communication, a class for
printing, a class for handling disk I/O,
and maybe a class for emailing, I would like each class to be able to
write to the common app log. From the
reply to my last post, it looked like I should be considering
'Singletons'. But, where in the app's code do I put this
'Singleton' so that each class knows of it, how do I tell each class the
'Singleton' exists, and how does each class use it,
as for instance to open the log, write an entry, and close the log?
Most of what I've read describes the 'Singleton' itself and it's
advantages/disadvantages, but I haven't
found anything that says 'put it here so it will be seen by all', 'do this
to use the singleton'. The same thing
seems to be true of 'static'. Most of the documentation seems to say what
'statics' are, why they are,etc.
That's fine, but as a newbie, I'm looking for something that tells me:
"if you want to use a 'static' and want it to be seen by the app, and
any class in the app, put it here,
declare it like this, and use it like this"?
For some reason, I may be 'looking' at the correct documentation,
tutorials, but I'm just not 'seeing' the information
 
Back
Top