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 Shing Hing Man <ma...@yahoo.com> on 2014/08/02 19:09:23 UTC

How to specify a log output folder in RollingFileAppender

Hi,
  I am trying to set up llog4net  to use RollingFileAppender in  F# in VS 2013. 


 <appender name="Roll" type="log4net.Appender.RollingFileAppender">
      <file      value="log_"/>
      <appendToFile value="true"/>
      <rollingStyle value="Date"/>
      <staticLogFileName value="false" />
      <datePattern value="yyyy_MM_dd.'txt'"/>
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger - %m%n" />
      </layout>
    </appender>

The above works. The log file log_2014_08_02.txt ends up  in {project}/bin/Debug directory.

However, I would like the log file to be in c:\ ,say. 

I have tried 

     <file      value="c:\log_"/>
and 

   <file      value="${HOMEDRIVE}\log_"/>
but none of the above works. 


How to set up <file> so that the output directory is in c:\  ? 

Thanks in advance for your assistance!

Shing

Re: How to specify a log output folder in RollingFileAppender

Posted by Shing Hing Man <ma...@yahoo.com>.
I have not decided where to put my logs yet -   within the project folder or outside. 
Thanks for the advice!

Shing 



On Saturday, 2 August 2014, 21:15, d_k <ma...@gmail.com> wrote:
 


You should probably reconsider having your program require administrator privileges just to write the log to the C: drive.
Perhaps a sub directory on the C: drive should be good enough? Or the application's own directory?
Also, if your program generates a lot of logs you should probably write them to a different drive to prevent it from filling all the space on the C: drive.
Or make sure you have some sort of an automatic way to delete old logs like a scheduled task independent of your program.




On Sat, Aug 2, 2014 at 10:59 PM, Shing Hing Man <ma...@yahoo.com> wrote:

Hi,
>  Running VS as administrator allows me to output the log to C:\. 
>
>
>
>Thanks!
>
>
>Shing 
>
>
>
>
>On Saturday, 2 August 2014, 20:28, d_k <ma...@gmail.com> wrote:
> 
>
>
>In order to write to the C: drive your application should run as an administrator. Run it as an Administrator and see if it helps.
>
>You can also configure log4net internal logging to see why it fails or download the source and attach it.
>
>To enable the internal logging add the following to your app.config:
>
>  <appSettings>
>    <add key="log4net.Internal.Debug" value="true"/>
>  </appSettings>
>  <system.diagnostics>
>    <trace autoflush="true">
>      <listeners>
>        <add
>        name="textWriterTraceListener"
>        type="System.Diagnostics.TextWriterTraceListener"
>        initializeData="log4net-debug.txt" />
>      </listeners>
>    </trace>
>  </system.diagnostics>
>
>
>
>
>On Sat, Aug 2, 2014 at 8:09 PM, Shing Hing Man <ma...@yahoo.com> wrote:
>
>Hi,
>>  I am trying to set up llog4net  to use RollingFileAppender in  F# in VS 2013. 
>>
>>
>>
>> <appender name="Roll" type="log4net.Appender.RollingFileAppender">
>>      <file      value="log_"/>
>>      <appendToFile value="true"/>
>>      <rollingStyle value="Date"/>
>>      <staticLogFileName value="false" />
>>      <datePattern value="yyyy_MM_dd.'txt'"/>
>>      <layout type="log4net.Layout.PatternLayout">
>>        <conversionPattern value="%date [%thread] %-5level %logger - %m%n" />
>>      </layout>
>>    </appender>
>>
>>
>>The above works. The log file log_2014_08_02.txt ends up  in {project}/bin/Debug directory.
>>
>>
>>However, I would like the log file to be in c:\ ,say. 
>>
>>I have tried 
>>
>>     <file      value="c:\log_"/>
>>and 
>>
>>   <file      value="${HOMEDRIVE}\log_"/>
>>but none of the above works. 
>>
>>
>>
>>How to set up <file> so that the output directory is in c:\  ? 
>>
>>Thanks in advance for your assistance!
>>
>>
>>Shing
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>
>
>

Re: How to specify a log output folder in RollingFileAppender

Posted by d_k <ma...@gmail.com>.
You should probably reconsider having your program require administrator
privileges just to write the log to the C: drive.
Perhaps a sub directory on the C: drive should be good enough? Or the
application's own directory?
Also, if your program generates a lot of logs you should probably write
them to a different drive to prevent it from filling all the space on the
C: drive.
Or make sure you have some sort of an automatic way to delete old logs like
a scheduled task independent of your program.


On Sat, Aug 2, 2014 at 10:59 PM, Shing Hing Man <ma...@yahoo.com> wrote:

> Hi,
>   Running VS as administrator allows me to output the log to C:\.
>
> Thanks!
>
> Shing
>
>
>   On Saturday, 2 August 2014, 20:28, d_k <ma...@gmail.com> wrote:
>
>
> In order to write to the C: drive your application should run as an
> administrator. Run it as an Administrator and see if it helps.
>
> You can also configure log4net internal logging to see why it fails or
> download the source and attach it.
>
> To enable the internal logging add the following to your app.config:
>
>   <appSettings>
>     <add key="log4net.Internal.Debug" value="true"/>
>   </appSettings>
>   <system.diagnostics>
>     <trace autoflush="true">
>       <listeners>
>         <add
>         name="textWriterTraceListener"
>         type="System.Diagnostics.TextWriterTraceListener"
>         initializeData="log4net-debug.txt" />
>       </listeners>
>     </trace>
>   </system.diagnostics>
>
>
> On Sat, Aug 2, 2014 at 8:09 PM, Shing Hing Man <ma...@yahoo.com> wrote:
>
> Hi,
>   I am trying to set up llog4net  to use RollingFileAppender in  F# in VS
> 2013.
>
>  <appender name="Roll" type="log4net.Appender.RollingFileAppender">
>       <file      value="log_"/>
>       <appendToFile value="true"/>
>       <rollingStyle value="Date"/>
>       <staticLogFileName value="false" />
>       <datePattern value="yyyy_MM_dd.'txt'"/>
>       <layout type="log4net.Layout.PatternLayout">
>         <conversionPattern value="%date [%thread] %-5level %logger - %m%n"
> />
>       </layout>
>     </appender>
>
> The above works. The log file log_2014_08_02.txt ends up  in
> {project}/bin/Debug directory.
>
> However, I would like the log file to be in c:\ ,say.
> I have tried
>     <file      value="c:\log_"/>
> and
>   <file      value="${HOMEDRIVE}\log_"/>
> but none of the above works.
>
> How to set up <file> so that the output directory is in c:\  ?
> Thanks in advance for your assistance!
>
> Shing
>
>
>
>
>
>
>
>
>
>
>

Re: How to specify a log output folder in RollingFileAppender

Posted by Shing Hing Man <ma...@yahoo.com>.
Hi,
  Running VS as administrator allows me to output the log to C:\. 


Thanks!

Shing 



On Saturday, 2 August 2014, 20:28, d_k <ma...@gmail.com> wrote:
 


In order to write to the C: drive your application should run as an administrator. Run it as an Administrator and see if it helps.

You can also configure log4net internal logging to see why it fails or download the source and attach it.

To enable the internal logging add the following to your app.config:

  <appSettings>
    <add key="log4net.Internal.Debug" value="true"/>
  </appSettings>
  <system.diagnostics>
    <trace autoflush="true">
      <listeners>
        <add
        name="textWriterTraceListener"
        type="System.Diagnostics.TextWriterTraceListener"
        initializeData="log4net-debug.txt" />
      </listeners>
    </trace>
  </system.diagnostics>




On Sat, Aug 2, 2014 at 8:09 PM, Shing Hing Man <ma...@yahoo.com> wrote:

Hi,
>  I am trying to set up llog4net  to use RollingFileAppender in  F# in VS 2013. 
>
>
>
> <appender name="Roll" type="log4net.Appender.RollingFileAppender">
>      <file      value="log_"/>
>      <appendToFile value="true"/>
>      <rollingStyle value="Date"/>
>      <staticLogFileName value="false" />
>      <datePattern value="yyyy_MM_dd.'txt'"/>
>      <layout type="log4net.Layout.PatternLayout">
>        <conversionPattern value="%date [%thread] %-5level %logger - %m%n" />
>      </layout>
>    </appender>
>
>
>The above works. The log file log_2014_08_02.txt ends up  in {project}/bin/Debug directory.
>
>
>However, I would like the log file to be in c:\ ,say. 
>
>I have tried 
>
>     <file      value="c:\log_"/>
>and 
>
>   <file      value="${HOMEDRIVE}\log_"/>
>but none of the above works. 
>
>
>
>How to set up <file> so that the output directory is in c:\  ? 
>
>Thanks in advance for your assistance!
>
>
>Shing
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

Re: How to specify a log output folder in RollingFileAppender

Posted by d_k <ma...@gmail.com>.
In order to write to the C: drive your application should run as an
administrator. Run it as an Administrator and see if it helps.

You can also configure log4net internal logging to see why it fails or
download the source and attach it.

To enable the internal logging add the following to your app.config:

  <appSettings>
    <add key="log4net.Internal.Debug" value="true"/>
  </appSettings>
  <system.diagnostics>
    <trace autoflush="true">
      <listeners>
        <add
        name="textWriterTraceListener"
        type="System.Diagnostics.TextWriterTraceListener"
        initializeData="log4net-debug.txt" />
      </listeners>
    </trace>
  </system.diagnostics>


On Sat, Aug 2, 2014 at 8:09 PM, Shing Hing Man <ma...@yahoo.com> wrote:

> Hi,
>   I am trying to set up llog4net  to use RollingFileAppender in  F# in VS
> 2013.
>
>  <appender name="Roll" type="log4net.Appender.RollingFileAppender">
>       <file      value="log_"/>
>       <appendToFile value="true"/>
>       <rollingStyle value="Date"/>
>       <staticLogFileName value="false" />
>       <datePattern value="yyyy_MM_dd.'txt'"/>
>       <layout type="log4net.Layout.PatternLayout">
>         <conversionPattern value="%date [%thread] %-5level %logger - %m%n"
> />
>       </layout>
>     </appender>
>
> The above works. The log file log_2014_08_02.txt ends up  in
> {project}/bin/Debug directory.
>
> However, I would like the log file to be in c:\ ,say.
> I have tried
>     <file      value="c:\log_"/>
> and
>   <file      value="${HOMEDRIVE}\log_"/>
> but none of the above works.
>
> How to set up <file> so that the output directory is in c:\  ?
> Thanks in advance for your assistance!
>
> Shing
>
>
>
>
>
>
>
>