Logging Enhancements – Part One

JK

Jeff Key

01/24/2019

There’s an awkward period in many romantic relationships where a person moves in with another person — but not completely. They still have their separate apartment “just in case” (can you blame them?), and with that apartment comes the snail mail. I don’t think I’m going out on a limb saying that 95% of postal mail is effectively useless and the remaining 5% skews very important. And after living with someone else for a few months, it’s easy to forget the mail and especially the periodic bills in the 5%.

Application logging can be similar. When different applications and components log to different end points, it can be easy to miss something important. InRule has provided a number of traditional logging options to date and last year added an option that’s equivalent to a postal service Change of Address form.

If you use the InRule SDK in your own apps and use one of the more popular logging frameworks for .NET (Serilog, Log4Net, NLog or Loupe), InRule can now write directly to your existing logging framework by simply adding one line to your application’s config file. For example, if your app uses Serilog to write to Azure Table Storage, InRule will use the existing instance of Serilog and your InRule log messages will find their way into the same Azure table as the rest of your application’s log messages.

All you need to do is add the LibraryLogger to your existing collection of InRule loggers:

<logger typeName="InRule.Repository.Logging.Loggers.LibraryLogger, InRule.Repository" />

If you don’t already have InRule logging configured in your application, you can set it up by adding the following:

<configSections>
  <section name="inrule.logging" type="InRule.Repository.Logging.Configuration.LoggingSectionHandler, InRule.Repository" />
 </configSections>
 <inrule.logging>

 <group typeName="InRule.Repository.Logging.Loggers.LoggerGroup, InRule.Repository" level="Info">
  <logger typeName="InRule.Repository.Logging.Loggers.LibraryLogger, InRule.Repository" />
 </group>
</inrule.logging>

Please note that you can still use other InRule loggers in addition to the LibraryLogger. For example, you may want to use the LibraryLogger to write info-level messages to your application’s log, but write error messages to your Windows Event Log — or vice versa.

This functionality was introduced in version 5.2 and we hope you find it useful. Please reach out if you have any feedback. We love to hear from our customers.