Dofactory.com
Dofactory.com
 Back to list
Views:   7.5K
Replies:  1
Archived

RE: Log project

How do I set up different logging severity levels for different log types?  For instance, I can set the log severity to Info, but that covers all log types, do I just need to add a log severity for each type of log?  That way I can set the logseverity for email and the log severity for file and the log severity for console.  And yes they need to be different, since when the log event happens if it is an error it should not only log into the log file but also send an email, but if it is info then it should only write to the log file and not send an email. 

Or is there something I am missing?
Tony Blogumas, Jun 28, 2011
Reply 1

Hi
[The question needs to be more clear, but somehow am able to get what you are looking for.]

My assumption:

When you get an error, you would pass your error object to an logging class, which will decide at runtime-
if it is an error (?) or just an info (?) and log that into appropriate source (like file, DB etc)

If yes, I would recommend to go for a Chain Of Responsibility pattern.

Steps I could think of :"

1) Build the chain of Loggers (File, email, DB etc.,)

2) Pass the error (or Info) obejct to First in the chain , say File Logger, this Class will decide if it need to log, if yes, will log and then send your "Error object" to next in the chain - say "Email Logger (sender)"

3) Email Logger Class will check if it eligible to be sent , if yes will send email and will pass it to next in the chain, say DB.

4) DB Logger will check and lets us assume its not a eligible one and will end the chain signallig the completion.

Please refer to my blog where I have talked more about this pattern (of course with  a Builder Pattern variation)

http://techietarriq.blogspot.com/2011_02_01_archive.html

Hope this helps.

Thanks,

Tarriq Ferrose Khan

Tarriq Ferrose Khan, Aug 15, 2011
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.