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 Steve Whitley <st...@nullfx.com> on 2006/06/08 00:02:46 UTC

problems with windows service

Hello,

I have created a windows service, installed it to use the (at first) the 
local system admin account, then the local system account.  I have 
verified that I have the necessary permissions (by simply creating a 
file & writing to it), but log4net is showing Is...Enabled = false on 
all levels.

my config looks like this:

<configuration>
   <configSections>
       <section
             name="log4net"
             type="System.Configuration.IgnoreSectionHandler" />
   </configSections>
   <appSettings>
      <!-- other settings ->
   </appSettings>
   <log4net>
       <appender
             name="RollingLogFileAppender"
             type="log4net.Appender.RollingFileAppender">
           <file
value="${windir}/System32/LogFiles/CompanyName/ServiceName/ServiceName.log" 
/>
           <appendToFile value="true" />
           <rollingStyle value="Date" />
           <datePattern value="yyyy-MM-dd" />
           <staticLogFileName value="true" />
           <layout type="log4net.Layout.PatternLayout">
               <header value="[Header]&#13;&#10;" />
               <footer value="[Footer]&#13;&#10;" />
               <conversionPattern value="...(removed for email)" />
           </layout>
       </appender>
       <root>
           <level value="ALL" />
           <appender-ref ref="RollingLogFileAppender" />
       </root>
   </log4net>
</configuration>


I have the assembly level attribute to look for the config info in 
AssemblyInfo.cs

using log4net.Config;

[assembly: XmlConfigurator(Watch=true)]

If I run the executable as a normal executable, all logging happens as 
it should, but when it runs as a service nothing happens (debugging 
shows that's because the Is...Enabled is false).

anything I've left out that would enable my service to log?

thanks,
Steve

Re: problems with windows service

Posted by Steve Whitley <st...@nullfx.com>.
DOMConfiguratorAttribute has been depreciated for 
XmlConfiguratorAttribute, but by specifying my config file (Thanks!) 
things are working now.

My "AssemblyName" and "default namespace" are different, which is why 
I'm guessing the config wasnt getting loaded.

Thanks!
--Steve

Bejugam, Raghavendra (GE Comm Fin, non-ge) wrote:

>I think you are missing this in the AssemblyInfo.VB
><Assembly: log4net.Config.DOMConfigurator(ConfigFile:="log4net.config.xml", Watch:=True)> 
>
>-----Original Message-----
>From: Steve Whitley [mailto:steve@nullfx.com]
>Sent: Wednesday, June 07, 2006 6:03 PM
>To: 'Log4NET User'
>Subject: problems with windows service
>
>
>Hello,
>
>I have created a windows service, installed it to use the (at first) the 
>local system admin account, then the local system account.  I have 
>verified that I have the necessary permissions (by simply creating a 
>file & writing to it), but log4net is showing Is...Enabled = false on 
>all levels.
>
>my config looks like this:
>
><configuration>
>   <configSections>
>       <section
>             name="log4net"
>             type="System.Configuration.IgnoreSectionHandler" />
>   </configSections>
>   <appSettings>
>      <!-- other settings ->
>   </appSettings>
>   <log4net>
>       <appender
>             name="RollingLogFileAppender"
>             type="log4net.Appender.RollingFileAppender">
>           <file
>value="${windir}/System32/LogFiles/CompanyName/ServiceName/ServiceName.log" 
>/>
>           <appendToFile value="true" />
>           <rollingStyle value="Date" />
>           <datePattern value="yyyy-MM-dd" />
>           <staticLogFileName value="true" />
>           <layout type="log4net.Layout.PatternLayout">
>               <header value="[Header]&#13;&#10;" />
>               <footer value="[Footer]&#13;&#10;" />
>               <conversionPattern value="...(removed for email)" />
>           </layout>
>       </appender>
>       <root>
>           <level value="ALL" />
>           <appender-ref ref="RollingLogFileAppender" />
>       </root>
>   </log4net>
></configuration>
>
>
>I have the assembly level attribute to look for the config info in 
>AssemblyInfo.cs
>
>using log4net.Config;
>
>[assembly: XmlConfigurator(Watch=true)]
>
>If I run the executable as a normal executable, all logging happens as 
>it should, but when it runs as a service nothing happens (debugging 
>shows that's because the Is...Enabled is false).
>
>anything I've left out that would enable my service to log?
>
>thanks,
>Steve
>
>  
>

RE: problems with windows service

Posted by "Bejugam, Raghavendra (GE Comm Fin, non-ge)" <ra...@ge.com>.
I think you are missing this in the AssemblyInfo.VB
<Assembly: log4net.Config.DOMConfigurator(ConfigFile:="log4net.config.xml", Watch:=True)> 

-----Original Message-----
From: Steve Whitley [mailto:steve@nullfx.com]
Sent: Wednesday, June 07, 2006 6:03 PM
To: 'Log4NET User'
Subject: problems with windows service


Hello,

I have created a windows service, installed it to use the (at first) the 
local system admin account, then the local system account.  I have 
verified that I have the necessary permissions (by simply creating a 
file & writing to it), but log4net is showing Is...Enabled = false on 
all levels.

my config looks like this:

<configuration>
   <configSections>
       <section
             name="log4net"
             type="System.Configuration.IgnoreSectionHandler" />
   </configSections>
   <appSettings>
      <!-- other settings ->
   </appSettings>
   <log4net>
       <appender
             name="RollingLogFileAppender"
             type="log4net.Appender.RollingFileAppender">
           <file
value="${windir}/System32/LogFiles/CompanyName/ServiceName/ServiceName.log" 
/>
           <appendToFile value="true" />
           <rollingStyle value="Date" />
           <datePattern value="yyyy-MM-dd" />
           <staticLogFileName value="true" />
           <layout type="log4net.Layout.PatternLayout">
               <header value="[Header]&#13;&#10;" />
               <footer value="[Footer]&#13;&#10;" />
               <conversionPattern value="...(removed for email)" />
           </layout>
       </appender>
       <root>
           <level value="ALL" />
           <appender-ref ref="RollingLogFileAppender" />
       </root>
   </log4net>
</configuration>


I have the assembly level attribute to look for the config info in 
AssemblyInfo.cs

using log4net.Config;

[assembly: XmlConfigurator(Watch=true)]

If I run the executable as a normal executable, all logging happens as 
it should, but when it runs as a service nothing happens (debugging 
shows that's because the Is...Enabled is false).

anything I've left out that would enable my service to log?

thanks,
Steve