473,672 Members | 2,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Thread based Error / Event Logging

2 New Member
Okay, I have NO idea if this is possible (or a good idea) but I am getting REALLY annoyed...

So I wrote this error logging class, to specs. It takes 3 objects as parameters, one for the exception, one for System.Relefect ion.MethodBase. GetCurrentMetho d(), and one for a Sql Data object (Data Adapter, Table Adapter, or SQL Command)... spawns a thread, saves info to a DB or dumps a strongly typed dataset to xml...

no worries.

BUT

Expand|Select|Wrap|Line Numbers
  1. try
  2. {
  3.      ///Do Stuff....
  4. }
  5. catch (Exception Ex)
  6. {
  7.      ErrorLogging.LogError(Ex, System.Reflection.MethodBase.GetCurrentMethod(), null);
  8.  
  9. }
This is a PITA, not to mention, difficult to change if something should change somewhere.

Is it possible to have some object watching a thread, suck in the relevant information (using Reflection, similar to how I am doing it now) and spawn a child/worker thread to do this? Then it just happens no matter where the exception is?

This would be a life saver (as well as helping migrate other apps to use this type of error logging). I would like to use it to prevent the app from job closing too if possible. If it traps an error, it should try to gracefully quit what it was doing and move on (button click, throws an error, it just discards what it was doing and ends the event)?
Sep 25 '08 #1
3 1079
pootle
68 New Member
Hi,

Just out of interest, have you not considered using a logging framework, something like log4net, or my personal favourite, NLog. They are both free and make life much easier - they help with the whole PITA thing. . .
Sep 25 '08 #2
CrashTECH
2 New Member
I am looking into it actually. It needs to do more than just log the Ex though. We have a local DB (offline application) that we want to store things to and/or write to XML. Do some other things if possible.

Do you know of any frameworks that support those types of things?
Sep 26 '08 #3
Frinavale
9,735 Recognized Expert Moderator Expert
Are you developing a web application?
If so, the Global.asax allows you to implement the Application_Err or method. This is called whenever an exception is not caught in the application.

-Frinny
Sep 26 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

31
2489
by: AlexeiOst | last post by:
Everywhere in documentation there are recommendations to use threads from thread pooling for relatively short tasks. As I understand, fetching a page or multiple pages (sometimes up to 50 but not tipical) from the Internet and doing some processing on those would be considered to be a big/long task for a thread from a pool. In our app it is possible to break the task into some small ones (thread per fetch and processing thereafter or event...
9
3068
by: mareal | last post by:
I have noticed how the thread I created just stops running. I have added several exceptions to the thread System.Threading.SynchronizationLockException System.Threading.ThreadAbortException System.Threading.ThreadInterruptedException System.Threading.ThreadStateException to see if I could get more information about why the thread stops running but that code is never executed. Any ideas on how I can debug this?
31
1510
by: AlexeiOst | last post by:
Everywhere in documentation there are recommendations to use threads from thread pooling for relatively short tasks. As I understand, fetching a page or multiple pages (sometimes up to 50 but not tipical) from the Internet and doing some processing on those would be considered to be a big/long task for a thread from a pool. In our app it is possible to break the task into some small ones (thread per fetch and processing thereafter or event...
7
1541
by: Brent | last post by:
Page1.aspx calls Page2.aspx like this: ---------------- Server.Execute("Page2.aspx"); --------------- Page2.aspx's Page_Load event calls a function, getMsgs().This function runs normally when it is called directly, as in ---------------
0
8404
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
8931
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
8828
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8608
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8680
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...
1
6238
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
5705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2819
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
2063
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.