Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's not only unit testing that will cause problems.</p> <p>Given that <a href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getentryassembly.aspx" rel="nofollow">GetEntryAssembly() can return null when a managed assembly has been loaded from an unmanaged application</a> and also that <a href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly.codebase" rel="nofollow">CodeBase can contain a URL for assemblies downloaded from the Internet, and is not set for assemblies loaded from the GAC</a>, I would avoid attempting this approach for a general-purpose logging library.</p> <p>If that's not enough to convince you, other problems are (a) non-privileged users won't have write access to CommonApplicationData, and (b) multiple instances of your application attempting to write to the same log file will be a problem.</p> <p>Instead, I would define the location of the log file in configuration.</p> <blockquote> <p>Where would you suggest I put it to avoid this problem?</p> </blockquote> <p>As I said, I would define it in configuration (e.g. an appSetting in app.config). This is the most flexible. If you want to put it under CommonApplicationData, you can use an environment variable that you expand using the <code>Environment.ExpandEnvironmentVariables</code> method when reading from the configuration file. For example:</p> <pre><code>&lt;appSettings&gt; &lt;add key="logFile" value="%ALLUSERSPROFILE%\MyApp\MyLogFile.log" /&gt; ... &lt;/appSettings&gt; </code></pre> <p>You still have to solve the problem of giving access to non-privileged users, and avoiding contention when accessing from multiple instances. You say your underlying logging library supports concurrent access, but be aware that this will have a potential performance cost, depending on how verbose your logging is.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload