In the context of your application, can you find out the real (and meaningful) name for this instance? Can I run multiple instances with a command line parameter that represents the name of the application? If you can “know” a useful name for the application, you can save this name in the GlobalDiagnosticsContext and use the GlobalDiagnosticsContext LayoutRenderer to create your file name.
So your configuration might look something like this:
<target name="logfile" xsi:type="File"
fileName="${specialfolder:folder=ApplicationData}/MyCompany/CRM/crm_${gdc:item=application}.log"
deleteOldFileOnStartup ="true"
layout="${longdate} ${message} ${exception:format=tostring}"/>
In the application startup logic, you should install gdc as follows:
GlobalDiagnosticsContext.set("application", GetApplicationNameFromCommandLineArgs());
Each application will write to its own log file, named based on the command line parameter.
Good luck
source
share