<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      autoReload="true"
      throwConfigExceptions="true"
      internalLogLevel="Info"
      internalLogFile="/Logs/internal-nlog-AspNetCore.txt">

    <extensions>
        <add assembly="NLog.Web.AspNetCore"/>
    </extensions>

    <targets>
        <!-- Journalisation complète -->
        <target xsi:type="File" name="allfile"
                fileName="/Logs/nlog-all-${shortdate}.log"
                layout="${longdate}|${level:uppercase=true}|${logger}|${message} ${exception:format=tostring}" />

        <!-- Journalisation spécifique avec détails web -->
        <target xsi:type="File" name="ownfile-web"
                fileName="/Logs/nlog-own-${shortdate}.log"
                layout="${longdate}|${level:uppercase=true}|${logger}|${message} ${exception:format=tostring}|${aspnet-request-url:whenEmpty=NoRequest}" />

        <!-- Console pour debug immédiat -->
        <target xsi:type="Console" name="console"
                layout="${longdate}|${level:uppercase=true}|${logger}|${message}" />
    </targets>

    <rules>
        <!-- Vos logs d'application en Debug+ -->
        <logger name="Webzine.WebApplication.*" minlevel="Debug" writeTo="allfile,ownfile-web,console" />

        <!-- Logs Microsoft en Warning+ sauf Hosting.Lifetime -->
        <logger name="Microsoft.*" minlevel="Warn" writeTo="allfile" final="true" />
        <logger name="Microsoft.Hosting.Lifetime*" minlevel="Info" writeTo="allfile,console" final="true" />

        <!-- Tous les autres logs (y compris System) en Info+ -->
        <logger name="*" minlevel="Info" writeTo="allfile" />
    </rules>
</nlog>