Click here to Skip to main content
15,907,687 members
Home / Discussions / C#
   

C#

 
QuestionUnderstanding Async / Await Pin
zephaneas25-Mar-15 10:07
zephaneas25-Mar-15 10:07 
AnswerRe: Understanding Async / Await Pin
F-ES Sitecore25-Mar-15 12:23
professionalF-ES Sitecore25-Mar-15 12:23 
SuggestionRe: Understanding Async / Await Pin
Richard Deeming26-Mar-15 2:57
mveRichard Deeming26-Mar-15 2:57 
QuestionUse EPPlus to Read 1st Column Of Excel Workbook Into Array (.xlsx) Pin
Hellfire123125-Mar-15 4:42
Hellfire123125-Mar-15 4:42 
AnswerRe: Use EPPlus to Read 1st Column Of Excel Workbook Into Array (.xlsx) Pin
OriginalGriff25-Mar-15 5:25
mveOriginalGriff25-Mar-15 5:25 
QuestionEffective way of writing logs in web service in C#.net Pin
manishchourasia200025-Mar-15 0:19
professionalmanishchourasia200025-Mar-15 0:19 
AnswerRe: Effective way of writing logs in web service in C#.net Pin
Elegantly Wasted25-Mar-15 0:51
Elegantly Wasted25-Mar-15 0:51 
AnswerRe: Effective way of writing logs in web service in C#.net Pin
jschell25-Mar-15 11:28
jschell25-Mar-15 11:28 
manishchourasia2000 wrote:
I want to know what is the effective to way to write logs in web service


Effective is a loaded word. If you have specifics objective requirements then you should determine what those are first.

manishchourasia2000 wrote:
I personally feel that we should log this to flat files instead of database using Trace Listener


First, you might want to define exactly what "log" means.

My criteria
- I differentiated between 'development' logs and 'business' logs.
- Development logs are solely and completely intended to help developers debug problems that occurred during production.
- Development logs are NOT intended to be 'easy' tools for IT or support to figure out problems. Logs can exist for those purposes but those are business logs (a type of business log.)
- IT and support are welcome to use development logs and can make suggestions for either adding or removing content but they do not dictate it.
- Development logs are NOT intended to provide support for developing code. A developer might use it when actually doing the development but what remains in the delivered code must be suited for use in production. And example of this that logs can not have things like "Now in the loop" or print out every time a polling loop is entered.
- Failures in the development logs cannot stop the business functionality from running.
- Business logs should be handled like any other business requirement where a product owner delivers requirements for it, development implements it, and QA validates it. Failure to write a business log can stop business functionality. That should be specified as part of the requirements


A business log(s) might include things like the following
- A user logged in
- A user deleted a record
- The IP a user request came from.
- Expected errors which are not reported via other mechanisms.

Finally a log cannot exist solely in a database because writing to the database might fail

manishchourasia2000 wrote:
Writing a snippet for logging is not a big deal


Use a 3rd party library. As per the other response for Log4net or I have used NLog. You might want to actually research logging libraries. One criteria I used the last time was how active the log library updates were. At least when I looked years ago log4net was not being actively maintained while NLog was. That could have changed.

manishchourasia2000 wrote:
I am bit worry for the following queries.


Do not attempt to log too much.
- It provides no benefit.
- It complicates maintenance
- The sheer volume becomes a problem because it takes space
- Because it takes space an inclination develops to get rid of the 'old' stuff which might be needed later.
- The volume makes it hard to find actual problems.

A developer must determine critical points in the application and the log appropriately for those points. Some examples
- Complex Database operations, logging attributes of those.
- Database exceptions
- Exceptions from any external sources such as Rest/Http calls. External system calls should ALWAYS be wrapped in exception handles and exceptions handled.
- Successful/unsuccessful jobs that run at large intervals. Like once a day. But not once a second.
- Major operations that end in expected failures.
- Requests into the system and Responses to those requests.

Security concerns should be address in the above as, for example, logging a password/hash should never occur.

Unexpected exceptions are always something to log. But
- Avoid logging expected exceptions. They are after expected.
- Do not double log exceptions. That happens when someone logs it then throws the same exception again. Either log it and handle it or do not catch it in the first place

Naturally you should ALWAYS catch all unexpected exceptions and attempt to log them somewhere.
QuestionCould not cal the repaint on invalidate Pin
Sarita S24-Mar-15 22:54
Sarita S24-Mar-15 22:54 
AnswerRe: Could not cal the repaint on invalidate Pin
OriginalGriff24-Mar-15 23:06
mveOriginalGriff24-Mar-15 23:06 
AnswerRe: Could not cal the repaint on invalidate Pin
OriginalGriff25-Mar-15 2:19
mveOriginalGriff25-Mar-15 2:19 
QuestionScheduler without using timer class in c# Pin
Member 1138787724-Mar-15 19:48
Member 1138787724-Mar-15 19:48 
AnswerRe: Scheduler without using timer class in c# Pin
Pete O'Hanlon24-Mar-15 20:13
mvePete O'Hanlon24-Mar-15 20:13 
QuestionSingleton vs Whatever Else Quandary Pin
Z.C.M.24-Mar-15 16:58
professionalZ.C.M.24-Mar-15 16:58 
AnswerRe: Singleton vs Whatever Else Quandary Pin
Mycroft Holmes24-Mar-15 17:09
professionalMycroft Holmes24-Mar-15 17:09 
AnswerRe: Singleton vs Whatever Else Quandary Pin
Pete O'Hanlon24-Mar-15 19:32
mvePete O'Hanlon24-Mar-15 19:32 
GeneralRe: Singleton vs Whatever Else Quandary Pin
Z.C.M.25-Mar-15 4:00
professionalZ.C.M.25-Mar-15 4:00 
AnswerRe: Singleton vs Whatever Else Quandary Pin
jschell25-Mar-15 11:34
jschell25-Mar-15 11:34 
QuestionWhat is wrong with the structure of this code? Pin
Member 1147801824-Mar-15 0:25
Member 1147801824-Mar-15 0:25 
AnswerRe: What is wrong with the structure of this code? Pin
Ron Nicholson24-Mar-15 3:20
professionalRon Nicholson24-Mar-15 3:20 
GeneralRe: What is wrong with the structure of this code? Pin
Dave Kreskowiak24-Mar-15 3:48
mveDave Kreskowiak24-Mar-15 3:48 
GeneralRe: What is wrong with the structure of this code? Pin
Member 1147801824-Mar-15 11:06
Member 1147801824-Mar-15 11:06 
GeneralRe: What is wrong with the structure of this code? Pin
Ron Nicholson24-Mar-15 11:43
professionalRon Nicholson24-Mar-15 11:43 
AnswerRe: What is wrong with the structure of this code? Pin
Gerry Schmitz24-Mar-15 12:14
mveGerry Schmitz24-Mar-15 12:14 
Questionc# Pin
Member 1133602722-Mar-15 8:40
Member 1133602722-Mar-15 8:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.