Skip to content
ikopylov edited this page Jun 17, 2015 · 3 revisions

Steps:

  • Add reference to logger library
  • Add configuration section to your 'App.config':
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="LoggerConfigurationSection" type="Qoollo.Logger.Configuration.LoggerConfigurationSectionConfigClass, Qoollo.Logger" allowExeDefinition="MachineToApplication" requirePermission="false" />
  </configSections>

  <LoggerConfigurationSection xmlns="Qoollo.Logger.Configuration.LoggerConfigurationSection_NS">
    <logger logLevel="TRACE">
      <asyncQueueWrapper>
        <groupWrapper>
          <consoleWriter logLevel="INFO"
            template="{DateTime}. {Level}. \n At {StackSource}.{Class}::{Method}.\n Message: {Message}. {Exception, prefix = '\n Exception: ', valueOnNull=''}\n\n"/>
          <fileWriter logLevel="DEBUG" fileNameTemplate="logs/{DateTime, format = yyyy-MM-dd}.log"
            template="{DateTime}. {Level}. \n At {StackSource}.{Class}::{Method}.\n Message: {Message}. {Exception, prefix = '\n Exception: ', valueOnNull=''}\n\n"/>
          <fileWriter logLevel="ERROR" fileNameTemplate="logs/Errors_{DateTime, format = yyyy-MM-dd}.log"
            template="{DateTime}. {Level}. \n At {StackSource}.{Class}::{Method}.\n Message: {Message}. {Exception, prefix = '\n Exception: ', valueOnNull=''}\n\n"/>
        </groupWrapper>
      </asyncQueueWrapper>
    </logger>
  </LoggerConfigurationSection>

</configuration>
  • Use logger anywhere:
  Qoollo.Logger.LoggerDefault.Instance.Info("Hello world!");
    // or
  Qoollo.Logger.LoggerStatic.Info("Hello world!");  
Clone this wiki locally