Java to C# question - Logging API and processor

  • Thread starter Thread starter Sam
  • Start date Start date
S

Sam

I m trying to port a a Java app to C# and have two questions.

i) In Java there is a java.util.Logging package that can be used to log
at different levels. Is there an equivalent in C# ?

2) There is a Runtime.getRuntime.availableProcessors() method that
returns the number of available processors to the process.
How do I do that in C# ? I think I have to use a Win32 unmanaged API
call and can do that - but need some pointers on where I can find this info.

Thanks
/s
 
1) no. Not that I know of anyway, however there is a Trace log that is
easily usable. They are application specific and are set up in the
app.config file. They are often used for debugging, but not for real
logging. If you need to log events, use the EventLogger.

2) Environment.ProcessorCount. Use it like this:
int numProc = Environment.ProcessorCount;

Hope that helps.
jeremiah();
 
Thus wrote jeremiah,
1) no. Not that I know of anyway, however there is a Trace log that
is easily usable. They are application specific and are set up in the
app.config file. They are often used for debugging, but not for real
logging. If you need to log events, use the EventLogger.

Another option is Enterprise Library 2.0

Cheers,
 
Sam said:
I m trying to port a a Java app to C# and have two questions.

i) In Java there is a java.util.Logging package that can be used to log
at different levels. Is there an equivalent in C# ?

Aside from the other mentioned built-in mechanisms you can also use
Log4Net, a straight-forward clone of log4j, also hosted by Apache:
http://logging.apache.org/log4net/

I am using it for most of my applications to get decent logging
support.

Best Regards,
Martin
 
Back
Top