❔ Why is the Ecxepction not written in the Out TextWriter?
I try to write the Console to a File:
Thats the SyncTextWriter:
82 Replies
Does aynone know how i can write the error text too?
i tried already Console.Error but it does not looks like it
what exception are you expecting to be written?
any
that happans
i thought the Console.Error control that
but maybe im wrong
the
Console.Error
stream only captures things that get written to itYea
So how is the console knowing there is a Problem ?
what do you mean?
Is the console not Something to like a file
uhm
kind of?
what is your question?
So where does throw ecxeption... write into it
wherever you want
Nah i mean
Has it a own writer... Because i wanna get it to write it in my file too
what?
Has it a own writerwhat is "it"?
Is it possible to get the text of the console
yes, you're already doing it
Textwriter
But that is without the ecxeption things
that is with everything that there is
you are capturing everything that is being written to the Console
No throw error not
correct
But wjy
because you're not writing anything to
Console.Error
That means?
thrown Exceptions do not write themselves to the console
if you don't write anything to
Console.Error
then nothing will be written to Console.Error
and nothing will show up in your file, from Console.Error
Oh
So i need to impliment a method that throw a ecxeption and a log to error?
implement whatever logic you like to get whatever data you like into the error stream
you can write before you throw your own exceptions
you can write all exceptions that you catch
you can do both of those things
you can write only exceptions that bubble up to kill the whole application
you can write exceptions that you catch and solve
But it would not possible to get any ecxeption like even if any api doing it or c# (.net)
why wouldn't it?
How would it?
what exceptions do you want to write?
All
define "All"
All that extends from excaptions
okay, but which ones?
which instances?
you have described types of exceptions
Ok just for example a nullpointexcaption
great, which ones?
Which one?
yes, which
NullReferenceException
s?
which ones do you want to log?All
all that get created and thrown?
Yea
thrown from where?
Anywhere
no, you cannot do that
Ok
you cannot log things that happen in code that isn't yours
you have control over YOUR code
Oh ok
you can log wherever you might throw your own exceptions
Sad
not really
Well
But thx anyways
and you can log exceptions that bubble into your code
I impliment then a fatal method in my logger class
not really, you wouldn't want this anyway
Well but in can not write the same error as in the console
what?
what same error as what console?
I want to get the throw ecxeptions that get written in the console too
okay
Because that not saved in the console.out writer
so, when I asked you "what exception are you expecting to be written?" the correct answer was not "any"
the correct answer was "this specific exception that I'm seeing in the console"
and then show it
Well yea
Sry for that
show me
Im on the phone
I can not show yu
But the ecxeption does just get written in the console and not in my file
does this happen right before the app crashes?
I crash it my self to see if it works
Or what yu mean?
I mean
is this an exception that is occuring as your app crashes?
Yea
it is not being written to the console
that's the framework writing the exception to console that killed your app
your app has already died, and the Console has been deconstructed
So
I.E. just because you see it in the "Console" window, doesn't mean that it was written through the
Console
class
it was written directly, after your app was already spun downOh ok
if you want to catch exceptions that are killing your app, and log them, then do that
Then do what?
catch exceptions that are killing your app and log them
Yea but thats not possible for any excaptions or?
you don't want any exceptions
you want the exceptions that are killing your app
you want exceptions that bubble up through the entire app
But how can i catch it then
the same way you catch any exception
try
{
// Block of code to try
}
catch (Exception e)
{
// Block of code to handle errors
}
Yu mean Something like that
I mean exactly that
But how can k catch if it crash the program
by putting the
try
around "the program"Ohh
Yu smart
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.