Two years ago I wrote about the event log of Topobase. We introduced this new feature with Topobase 2008. For every Topobase crash which happens we add an entry in the log file: /log/ApplicationLog.xml. You find further details in the original blog post.
But the log is not only for crashes, we can also use it to log warnings, information messages or debug information. If you need to trace down a problem on customer side the answer could be in this file.
I'll try to explain how you can also log your events into the log file. Because like every other built-in Topobase functionality you can also access this one from your own plug-in!
First of all you have to add the log4net.dll as a reference to the solution. You find this assembly in the bin directory of the Topobase Client or Administrator. After you have done that you can get the log instance from the LogManager:
using log4net;
ILog log = LogManager.GetLogger(GetType());
The log instance now provides different logging methods. You can either log fatal events, errors, warnings, information events or debug events. Here is an example how to log an information message (with the formatting option applied):
log.InfoFormat("Date of today is: {0}", DateTime.Now);
That's it!
You should be aware that the user defines what should be logged and what not. Depending on the log level this message will now be written into the log file. In this case (an INFO event) the user has to set the log level as high as either ALL, DEBUG or INFO. If the log level is set to ERROR for instance, this message is not written to the log file. That's why you can (and should because of performance) check if the event will be written at all:
if (log.IsInfoEnabled)
{
log.InfoFormat("Date of today is: {0}", DateTime.Now);
}
If you need more information about the log4net API you find it in the log4net SDK reference: http://logging.apache.org/log4net/release/sdk/index.html