I have some external libraries that I am using that are logging to the console. I want these to log via log4net.
NOTE: I am NOT wanting to log to console from log4net, that should be straight forward.
What I have discovered thus far:
1) Console.setOut method allows using a different file stream.
1.1) Overriding memorystream seemed promising but there isn’t a chance for raising an event to notify of changes
2) Writing to a file from Console seems like a work around, where I can read the file to update the UI textbox with new logs
3) FileStreams can autoflush, this means automatic updating of information. This sort of concept is similar to what I am after?
Whats the best way to get the console information put into log4net so that it can publish console log items the same way as log4net is configured? Currently my log4net puts logs into the eventlog, into a databinded wpf textbox, and into a file.
Personally don’t know any other solution for this case other then you wrote:
ovewrite
outputof console pointing it to a fileread the file and add to a logger
To be notified about the change you can try to use
FileSystemWatcherhttp://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx.Or if you don’t want “real time notification”, canopen file
only for readand check with the timer if there is any row after last saved reader pointer position.But I think, the first option is much easier.
Hope this helps.