You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by aus1977 <au...@gmail.com> on 2008/04/23 14:48:18 UTC

Moving log4net config out of App.config

I need to move log4net configuration from app.config file and i have tryed
the following :

app.config file :
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="Log4NetConfiguration" value="log4net.config" />
  </appSettings>
</configuration>

log4net.config file:
<log4net>
    
    <appender name="Framework.Manager"
type="log4net.Appender.RollingFileAppender">
      <file value="Logs\Gogimon.Framework.Manager.log.txt" />
      <appendToFile value="true" />
      <rollingStyle value="Size" />
      <maxSizeRollBackups value="1" />
      <maximumFileSize value="500KB" />
      <staticLogFileName value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date %newline[%thread] %-5level %logger
[%ndc] &lt;%property{auth}&gt; - %message%newline%newline" />
      </layout>
    </appender>
    
<logger name="Framework.Manager" additivity="false">
      <level value="ALL" />
      <appender-ref ref="Gogimon.Framework.Manager" />
    </logger>
<log4net>

it is doesn't works 

-- 
View this message in context: http://www.nabble.com/Moving-log4net-config-out-of-App.config-tp16834575p16834575.html
Sent from the Log4net - Users mailing list archive at Nabble.com.


Re: Moving log4net config out of App.config

Posted by Karel Kral <kr...@volny.cz>.
If your file has suffix .config, you must use configuration section 
handler. See log4net doc and bellow:

<configuration>
   <configSections>
     <section name="log4net" 
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>

<log4net>

</log4net>

---------
Prostredi: C#, WinForms, VS2008 Pro, Vista business, CoreDuo, 4GB RAM
___________________________________________________
Karel Kral, senior developer
ANETE, s.r.o.
___________________________________________________

Dne 23.4.2008 14:48, aus1977 napsal(a):
> I need to move log4net configuration from app.config file and i have tryed
> the following :
> 
> app.config file :
> <?xml version="1.0" encoding="utf-8" ?>
> <configuration>
>   <appSettings>
>     <add key="Log4NetConfiguration" value="log4net.config" />
>   </appSettings>
> </configuration>
> 
> log4net.config file:
> <log4net>
>     
>     <appender name="Framework.Manager"
> type="log4net.Appender.RollingFileAppender">
>       <file value="Logs\Gogimon.Framework.Manager.log.txt" />
>       <appendToFile value="true" />
>       <rollingStyle value="Size" />
>       <maxSizeRollBackups value="1" />
>       <maximumFileSize value="500KB" />
>       <staticLogFileName value="true" />
>       <layout type="log4net.Layout.PatternLayout">
>         <conversionPattern value="%date %newline[%thread] %-5level %logger
> [%ndc] &lt;%property{auth}&gt; - %message%newline%newline" />
>       </layout>
>     </appender>
>     
> <logger name="Framework.Manager" additivity="false">
>       <level value="ALL" />
>       <appender-ref ref="Gogimon.Framework.Manager" />
>     </logger>
> <log4net>
> 
> it is doesn't works 
> 

RE: Moving log4net config out of App.config

Posted by "Walden H. Leverich" <Wa...@TechSoftInc.com>.
How are you "starting" the logging? We use log4net heavily in our apps,
and we always store the config in log4net.config, but we explicitly
start logging with something along the lines of:

string configFile =
Server.MapPath(ConfigurationManager.AppSettings["log4net-config-file"]);
log4net.Config.XmlConfigurator.ConfigureAndWatch(new
System.IO.FileInfo(configFile));

log = log4net.LogManager.GetLogger(
	System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
log.Info("-----------Logging Started------------");
log.Info("Application Started.");
log.InfoFormat("Watching log4net config file '{0}'", configFile); 

-- 
Walden H Leverich III
Tech Software
(516) 627-3800 x3051
WaldenL@TechSoftInc.com
http://www.TechSoftInc.com

Quiquid latine dictum sit altum viditur.
(Whatever is said in Latin seems profound.)

-----Original Message-----
From: aus1977 [mailto:aus1977@gmail.com] 
Sent: Wednesday, April 23, 2008 8:48 AM
To: log4net-user@logging.apache.org
Subject: Moving log4net config out of App.config


I need to move log4net configuration from app.config file and i have
tryed
the following :

app.config file :
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="Log4NetConfiguration" value="log4net.config" />
  </appSettings>
</configuration>

log4net.config file:
<log4net>
    
    <appender name="Framework.Manager"
type="log4net.Appender.RollingFileAppender">
      <file value="Logs\Gogimon.Framework.Manager.log.txt" />
      <appendToFile value="true" />
      <rollingStyle value="Size" />
      <maxSizeRollBackups value="1" />
      <maximumFileSize value="500KB" />
      <staticLogFileName value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date %newline[%thread] %-5level
%logger
[%ndc] &lt;%property{auth}&gt; - %message%newline%newline" />
      </layout>
    </appender>
    
<logger name="Framework.Manager" additivity="false">
      <level value="ALL" />
      <appender-ref ref="Gogimon.Framework.Manager" />
    </logger>
<log4net>

it is doesn't works 

-- 
View this message in context:
http://www.nabble.com/Moving-log4net-config-out-of-App.config-tp16834575
p16834575.html
Sent from the Log4net - Users mailing list archive at Nabble.com.