windows - Topshelf, NLog and File Permissions -


i have windows service application uses topshelf library , i'm installing in aws during cfn-init using handy command line features topshelf.

c:\handy_service\> handyservice.exe install start 

this installs service in registry , calls sc start, it's quite useful because checks service name matches expect , allows configure user service run using nice fluent api.

the installer code writes diagnostic logs nlog if service configured use nlog in general.

the problem this: installer runs default local administrator account ami starts , nlog file gets created user. when service starts network service user, doesn't have permission write nlog log file.

how can service write log file? i've thought setting permissions programmatically looks nasty , i'd have determine log file name generated dynamically based on ec2 instance id. also, it's not entirely obvious @ point log file first created. easiest hack might go having 2 nlog.configs , switching 1 out @ end of install after logger flushed. because there overlap in time between service starting , installer exiting, expect i'll lose few lines of logging here.

any clean suggestions appreciated!

in end went setting permissions on logs folder @ deploy time. it's pretty straightforward icacls, couple of lines in rake instance, assuming know logs folder going be:

sh %{icacls "#{logs_dir}" /grant "#{username}":(oi)(w)} 

not calling usenlog() in service config simple option, install-time errors go in windows event log in case.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -