Friday, May 18, 2012
 
The best way to analyze your logs! Minimize
 Log4Net Mail archive   

The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.

Subject: Getting RollingLogFileAppender to write to Windows LocalAppData directory
Prev Next
You are not authorized to post a reply.

Author Messages
JP O'Gorman

09/12/2008 1:05 PM  


Hello

I configured the RollingLogFileAppender in my application .config file
hoping that it would write my log file into the windows users local app data
directory.


What I did not realize is that ${LOCALAPPDATA} is a Vista only environmental
key and it's failure to resolve on XP machines caused unexplainable
performance issues.

Can another tell me if there is a recommended way to get the
RollingLogFileAppender to write the log file to the user's local app data
directory?

Many thanks,
John Paul O'Gorman

David Abrames

09/19/2008 4:34 PM  

Dear John,

I use the following in my log4net.xml file:

<appender name="File" type="log4net.Appender.RollingFileAppender">
        <file value="${APPDATA}\MyApp\Logs\MyApp_log.txt"/>
        <appendToFile value="false" />
        <rollingStyle value="Size" />
        <maxSizeRollBackups value="10" />
        <maximumFileSize value="10MB" />
        <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%d %c {%t} [%-5p] %M(%L)-%m%n"/>
        </layout>
</appender>

This resolves to "/Documents and Settings/MyLoginUser/Application
Data/MyApp/Logs" on XP
and to "/Users/MyLoginUser/AppData/Roaming/MyApp/Logs on Vista.

'MyLoginUser' is the user name of the logged in User and normally these
folders are hidden by default so the User has to change their folder view
settings to display hidden folders to 'SEE' these folders.

One issue we have run into and I am working on is that for non-admin users
the 'Logs' folder is not created by log4net on Vista.  I am working on my
this and how to work around it.

David


You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > Getting RollingLogFileAppender to write to Windows LocalAppData directory



ActiveForums 3.7

 

 

 

 

 

 

 

 

Log4Net Dashboard

Log analysis and monitoring made easy!

Log4Net Dashboard is a log viewer that can read log statements from a variety of logging output targets.

You can download a free developer version.

  

Check it out!

On the demonstration site you can try it  with live data.demo.l4ndash.com - Try Log4Net Dashboard with live data

The mail archive is a copy of all the mail sent to the mail address: log4net-user@logging.apache.org, organized as a forum.

If you would like to participate in the mail list, send a mail to log4net-user-subscribe@logging.apache.org.

More information about the mailing list is available on: http://logging.apache.org/log4net/support.html

 

A complete topic list is available and can be viewed here (warning, it takes some time to load)

 

Copyright 2005-2008 by FaktNet AS Terms Of Use Privacy Statement