I want to be able to route all error messages to error.log.txt and all information messages to info.log.txt (regardless of categories). Is it possible?
Thanks
I want to be able to route all error messages to error.log.txt and all information messages to info.log.txt (regardless of categories). Is it possible?
Thanks
It's very much possible. Since you haven't provided exact details I can provide a generic solution to this. Write an enum that defines the levels/categories of logging involved with your application (or better yet start a log class library if you're creating your own from scratch and place the enum in it).
public enum LogCategory
{
Info,
Error,
Fatal,
Debug
}
Now when you write a method for your logging to write to a log you could make the enum a required argument to the method.
public WriteToLog(string logMessage, LogCategory category)
{
switch(category)
{
case LogCategory.Info:
// write to Info.log.txt
break;
case LogCategory.Error:
case LogCategory.Fatal:
// write to Error.log.txt
break;
case LogCategory.Debug:
// write to Debug.log.txt
break;
default:
// validate more
break;
}
}
That will get you headed in the right direction.