Vostok.Logging.Log4net
Represents an adapter between Vostok logging interfaces and log4net.
If you're already using Log4net, but want to try Vostok.Logging, we have a special library Vostok.Logging.Log4net. You do not have to rewrite all logging. Create an adapter and you will get an Vostok facade from the available log.
First usage
Create an Log4net ILog
:
Create an adapter:
Work with it as with Vostok's ILog. Type any informational message:
Result:
Why that is? There were Log4net logs. Then you created an adapter to handle as the Vostok log. But everything inside remained the same. So on the console you see the Log4net format.
Example 1
Complement the example above. First of all, create a simple Vostok's file log:
Create a log that records information synchronously to the console and to a file. You have Log4net's log which output events on console and Vostok's log which output events in the file. A single entry point is required for synchronous entry. Create a composite log for it. Pass fileLog and adapter in the composite. The adapter is necessary because composite only accepts Vostok implementations.
The result will be such Log4net's formate in output on the console and Vostok's formate in the file:
Example 2
Create an event with added properties. Pass it in composite
:
Additionally, configure FileLog
to see added properties in the file:
The result will be such output on the console:
Log4net log's settings remained. Log didn't process properties.
You changed FileLogSettings
and saw all event information and even properties in the file.
Last updated