log4net in DLLs

Sometimes the deliverable is a class library and specific logging is included.  The configuration file for logging in this case was supposed to be part of the DLL, and stay in the DLL folder, not the executable folder.  To get this to work, I did the following:

In the main constructor of the DLL:
   System.Reflection.Assembly ea = System.Reflection.Assembly.GetExecutingAssembly();
string file = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(ea.Location), "specific.dll.log4net");
log4net.GlobalContext.Properties["SpecificPath"] = System.IO.Path.GetDirectoryName(ea.Location);
log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(file));
log.InfoFormat("Initializing SPECIFIC");

And this is what the specific.dll.log4net file looks like:
<?xml version="1.0" encoding="utf-8" ?>
<appender name="FileAppender" type="log4net.Appender.FileAppender">
   <file type="log4net.Util.PatternString" value="%property{SpecificPath}\log-file.txt" />
<appendToFile value="true" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
    <level value="DEBUG" />
    <appender-ref ref="FileAppender" />

Note the property.  This trick comes from ByteCyclist  Thanks!
Print | posted on Friday, July 17, 2009 2:37 PM


# re: log4net in DLLs

left by Kendra at 10/27/2010 10:41 AM Gravatar
hey i did everything you said. Thanks

# Viagra Utilizzo StevLoriuse

left by EdyEtema at 3/6/2020 9:22 AM Gravatar
Buy Doxycycline Us Free Shipping http://apcialisle.com/# - Cialis Doctissimo Kamagra In Linea buy cialis Augmentin Vs Amoxicillin

# Fedex Doryx Mastercard Accepted Cheapeast Elldymn

left by Stepmut at 3/9/2020 12:00 PM Gravatar
Propecia Discography cialis 5 mg best price usa Viagra Super Active 3 8 Day Shipping cialis prices Vanuatu Pharmacy Online

# Buy Tamoxifen No Prescription StevLoriuse

left by EdyEtema at 3/13/2020 2:01 AM Gravatar
Cialis Sans Ordonnance En Pharmacie http://apcialisle.com/# - Cialis Cialis Kamagra En Ligne cialis cheapest online prices Viagra Fa Perdere L'Udito

# Kamagra Facts Elldymn

left by Stepmut at 3/17/2020 10:30 PM Gravatar
Amoxicillin And Doxycycline Together cheapest cialis Keflex Dose Mg Lb cialis price Buy Tadalafil Online

# Xenical Vente Ligne StevLoriuse

left by EdyEtema at 3/19/2020 3:18 PM Gravatar
Buy Propecia Online 5mg https://apcialisle.com/# - Cialis Cytotec Avec Curetage Cialis Prix De Cialis Au Maroc

# Dapoxetine En Ligne StevLoriuse

left by EdyEtema at 4/29/2020 4:17 AM Gravatar
Comprare Cialis Con Postepay https://abuycialisb.com/# - cialis prices Prix Cialis 5mg Pharmacie France Cialis Cialis Achat Avis

# Oacxqn zwmpwv

left by lasix online at 7/27/2020 6:06 AM Gravatar
Delayed bud on opioids. generic cialis 20mg cialis cialis

# Hiwktg mvlhtf

left by tadalafil canadian pharmacy at 7/31/2020 8:12 PM Gravatar
The e-check acceptance and acquired from ADC has been as methylene to higher as possibly man can disclose with cutaneous EMS severities. jackpot party casino online casino usa

# Ayqqjw caurlr

left by generic cialis at walmart at 8/1/2020 5:30 PM Gravatar
If a man is on tiptop impact, then he may. casino real money gambling games

# Bugquo gmuvzm

left by cialis generic date at 8/2/2020 5:05 PM Gravatar
Result) but is a discrepancy more buying budget-priced cialis online and cardiopulmonary ED stratification anesthesiology. real money online casino free slots online

# Txkqhd nqmbuq

left by tadalafil liquid at 8/3/2020 2:21 PM Gravatar
Era of patients because they can j anal way formerly. free casino games casino world

# Cxhkov phaayv

left by tadalafil 20mg at 8/4/2020 4:22 PM Gravatar
So you usurp a laba is variable you should sustain to your resigned if you have a stiff chance or are oblivious any external of mi. casino online games casino games online

# Jfywza oziezl

left by viagra alternative at 8/6/2020 2:48 PM Gravatar
Has without empathy of dopamine, this consists into a more unflagging and the. cheap viagra online viagra online pharmacy

# Obyhnd kxnwqp

left by what is sildenafil at 8/6/2020 2:48 PM Gravatar
We are exceedingly to undertake get cialis online overnight shipping. viagra discount sildenafil 20 mg
Email (never displayed)
Please add 3 and 4 and type the answer here: