Sunday, March 10, 2019

Using text logging library in automated tests

In the next video, we are going to add text logging functionality to our Windows Service
You might ask, why do we need text logging?
We need it because it provides us a way to gain knowledge about the internal state of our Windows Service
A user interface is not available for Windows Services by default
And writing everything to the system log is not viable
That's why it is a common practice is to put information in text file
So that you can know what flow lead to an error or a service crash
I'm going to introduce you to Log4Net logging library
Apache Log4Net is a free & open source logging library
It is used to generate rolling text log files
Rolling means that the library is responsible for rolling the log files
In other words creating new files when the file size exceeds a set threshold or the date is changed
Log4Net can be used to write information to various logging targets including network and databases
Using a logging library means we're not reinventing the wheel.
It helps us to change what gets written to the log file based on certain configuration values
Now that you know why we're using a logging library, let's open Visual Studio and proceed further.

No comments:

Post a Comment

Feel free to talk back...