3

我遇到了一个问题,我需要我的用户能够在没有管理员权限的情况下运行我的应用程序,但同时,我需要 NLog 能够创建它的日志文件,它需要管理员权限才能在安装应用程序的同一文件夹。

我正在尝试在应用程序目录下创建一个名为 的目录Logs,并everyone-modify使用 inno setup 授予权限。我将设置我的 NLog 配置以写入这个新的 Logs 文件夹而不是应用程序目录,因此即使应用程序由非管理员运行,NLog 也有足够的权限来创建日志。

我的问题是,这是正确的方法吗?我对 NLog 或 InnoSetup 不是很有经验,所以我不确定我是否缺少某些东西,或者这是否会造成安全问题?

我的 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>

我的 InnoSetup 安装程序脚本Dirs部分是这样的

InnoSetup

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

0 回答 0