Creating folder for log files for NLog with InnoSetup

戏子无情 提交于 2019-12-07 23:47:53

问题


I'm having an issue where I need my users to be able to run my application without administrator rights, but at the same time, I need NLog to be able to create it's log files, which it needs administrator rights to create them in the same folder the application is installed in.

I'm trying to create a directory under the application directory, named Logs, and give everyone-modify permissions with inno setup. I'm going to set up my NLog config to write to this new Logs folder instead of the application directory, so even when the application is run by non-administrators, NLog has sufficient privileges to create the logs.

My question is, is this the proper way to do this? I'm not very experienced with NLog or InnoSetup, so I'm not sure if there is something I'm missing, or if this will possibly create security problems?

I have my NLog config section set up like so

NLog

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <targets>
    <target name="el" xsi:type="EventLog" log="ASI" layout="${message} ${exception:innerFormat=tostring:maxInnerExceptionLevel=10:format=tostring}" />
    <target name="fl" xsi:type="File" fileName="Logs\iDocClientLog.log" layout="${date}: ${message} ${exception:innerFormat=tostring:maxInnerExceptionLevel=10:format=tostring}" />
  </targets>
  <rules>
    <logger name="*" minlevel="Debug" writeTo="el,fl" />
  </rules>
</nlog>

And my InnoSetup installer script Dirs section is like this

InnoSetup

[Dirs]
Name: "{app}\Logs"; Permissions: everyone-modify

来源:https://stackoverflow.com/questions/17580222/creating-folder-for-log-files-for-nlog-with-innosetup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!