How to create a log file in appData folder. Path: C: \ Users \ MYNAME \ AppData \ Roaming \ Project \ My Project \ Application. As soon as my project starts, the project folder is created on this path, where this path is hard-coded. How to add a log file to this folder using log4net? I made changes to the configuration file
<?xml version="1.0"?> <configuration> <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/> </configSections> <log4net> <appender name="Console" type="log4net.Appender.ConsoleAppender"> <layout type="log4net.Layout.PatternLayout"> <!-- Pattern to output the caller file name and line number --> <conversionPattern value="%5level [%thread] (%file:%line) - %message%newline" /> </layout> </appender> <appender name="RollingFile" type="log4net.Appender.RollingFileAppender"> <file value="${APPDATA}\\Roaming\\Project\\My Project\\Application\\Log.txt"/> <appendToFile value="true" /> <maximumFileSize value="100KB" /> <maxSizeRollBackups value="10" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%level %thread %logger - %message%newline" /> </layout> </appender> <root> <level value="ALL" /> <appender-ref ref="Console" /> <appender-ref ref="RollingFile" /> </root> </log4net> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup> <system.serviceModel> <bindings /> <client /> </system.serviceModel> </configuration>
This does not create any files in this folder. And all permissions are granted by the Administrator.
roopini n
source share