<log4net>
  <!-- Root logger now INFO to reduce verbosity; adjust via environment if needed -->
  <root>
    <!-- Elevate to DEBUG so debug file appender receives events; other appenders filter their own ranges -->
    <level value="DEBUG" />
    <!-- <appender-ref ref="console" /> -->
    <!-- <appender-ref ref="debug" /> -->
    <!-- Uncomment the following line to log all data. -->
    <!-- <appender-ref ref="allLevelsFile" /> -->
    <appender-ref ref="errorFile" />
  </root>

  <!-- Console (general info/warnings) -->
  <appender name="console" type="log4net.Appender.ConsoleAppender">
    <threshold value="INFO" />
    <layout type="log4net.Layout.PatternLayout">
      <converter>
        <name value="messageSanitized" />
        <type value="SurePassIdApiServer.Logging.SanitizedMessagePatternConverter, SurePassIdApiServer" />
      </converter>
      <conversionPattern value="%date{ISO8601} %-5level [%thread] %logger: %messageSanitized%newline" />
    </layout>
  </appender>

  <!-- Debug (active in dev; threshold keeps production quieter) -->
  <appender name="debug" type="log4net.Appender.DebugAppender">
    <threshold value="DEBUG" />
    <layout type="log4net.Layout.PatternLayout">
      <converter>
        <name value="messageSanitized" />
        <type value="SurePassIdApiServer.Logging.SanitizedMessagePatternConverter, SurePassIdApiServer" />
      </converter>
      <conversionPattern value="%date{ISO8601} %-5level %logger: %messageSanitized%newline" />
    </layout>
  </appender>

  <!-- All levels file (complete stream DEBUG..FATAL for forensic tracing) -->
  <appender name="allLevelsFile" type="log4net.Appender.RollingFileAppender">
    <file value="logs\api-server-all.log" />
    <appendToFile value="true" />
    <rollingStyle value="Composite" />
    <datePattern value="-yyyyMMdd" />
    <maximumFileSize value="50MB" />
    <maxSizeRollBackups value="10" />
    <staticLogFileName value="false" />
    <preserveLogFileNameExtension value="true" />
    <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
    <layout type="log4net.Layout.PatternLayout">
      <converter>
        <name value="messageSanitized" />
        <type value="SurePassIdApiServer.Logging.SanitizedMessagePatternConverter, SurePassIdApiServer" />
      </converter>
      <conversionPattern value="%date{ISO8601} %-5level [%thread] %logger: %messageSanitized%newline" />
    </layout>
    <filter type="log4net.Filter.LevelRangeFilter">
      <levelMin value="DEBUG" />
      <levelMax value="FATAL" />
    </filter>
  </appender>

  <!-- Error/Fatal dedicated file -->
  <appender name="errorFile" type="log4net.Appender.RollingFileAppender">
    <file value="logs\api-server-error.log" />
    <appendToFile value="true" />
    <rollingStyle value="Date" />
    <datePattern value="-yyyyMMdd" />
    <staticLogFileName value="false" />
    <preserveLogFileNameExtension value="true" />
    <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
    <layout type="log4net.Layout.PatternLayout">
      <converter>
        <name value="messageSanitized" />
        <type value="SurePassIdApiServer.Logging.SanitizedMessagePatternConverter, SurePassIdApiServer" />
      </converter>
      <conversionPattern value="%date{ISO8601} %-5level [%thread] %logger: %messageSanitized%newline" />
    </layout>
    <filter type="log4net.Filter.LevelRangeFilter">
      <levelMin value="ERROR" />
      <levelMax value="FATAL" />
    </filter>
  </appender>
</log4net>
