ILMerge + Castle + Log4Net

At work we have recently merged the various Castle assemblies into one with ILMerge. It has worked great, but we found one gotcha with the Log4Net facility. Castle’s LoggingFacility class defines class types of various logging factories as static strings, which aren’t picked up by ILMerge.

The solution has two parts:
1. Use the CustomLoggerFactory config parameter:

<facility id="LoggingFacility" loggingApi="Custom" customLoggerFactory="Castle.Services.Logging.Log4netIntegration.Log4netFactory, <Your Merged Assembly>" type="Castle.Facilities.Logging.LoggingFacility, <Your Merged Assembly>" />

2. Place your actual logging configuration into a file called “log4net.config” and place that file in the same folder as the file that contains the above facility definition.

Sources: Castle-Project-Users mailing list and Castle Monorail docs.

Previous Post
Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: