Castle Logging Facility and log4net.Config.XmlConfigurator - log4net

Does the Castle Logging Facility support anything in the way of what log4Net.Config.XmlConfigurator.ConfigureAndWatch() does? I'd like to use the Windsor logging facility but I'd really like to be able to change the logging config at runtime as well. Can anyone point me in the direction of how I'd accomplish this?

According to this file in the Castle source repository, the Castle log4net implementation does (or can) do a ConfigureAndWatch. I haven't used Castle, so I can't comment on exactly how to take advantage of this. My first guess is that it should "just work". If you are using Castle and you can configure its logging to use log4net, you might already be getting ConfigureAndWatch. It is possible that ConfigureAndWatch only works if you configure log4net in its own config file (as opposed to the app.config or web.config). It should not be too difficult to test (if you are already using Castle) to see if ConfigureAndWatch works as expected.
If you are not using Castle already, you might want to wait for someone more familiar with Castle and Castle logging to post an answer.
Here are another SO post about Castle logging that you might find helpful:
This one shows log4net configuration in the app.config/web.config (the accepted answer is from February 2010. I don't know if there is more recent information available or not):
Logging with Castle.Facilities.Logging and log4net
Good luck!

Related

How do I rename nlog.config?

A while ago, I developed a WPF control and integrated into a third-party solution.
Just my luck, turns out the supplier also now use nlog (v2), which they have registered in the GAC. They don't currently use an nlog.config file, although they could do at some point.
I have used nlog v4, which isn't registered in the GAC but resides in the project's output folder instead. I do use an nlog.config file.
Two issues I would appreciate your advice with:
How would I isolate our nlog config file, can I rename it?
Would it be considered good practice to register my nlog.dll (v4) in the GAC also?
Your second question:
Would it be considered good practice to register my nlog.dll (v4) in the GAC also?
I would not recommend to use the GAC if it's not required. It makes upgrading more complicated and it's less transparent. NLog 4 is fully semver compliant, so it's easy to upgrade when keeping your nlog.dll in your local bin.

moving from log4cxx to log4net

I have a largish application that currently uses log4cxx as its logging system. However, these appears to be a dead project, and I cannot get it to work with Visual Studio 2013. As such, I am looking to move to log4net
Our project is a mixed C+/C# project, using .net 3.5, and the logging is pretty simple
What is the best way to handle this migration. Any particular problems that people would expect to see, any required changes to config files, etc.
Also, is there a simple tutorial on how to use log4net. Unless I'm misreading it, it appears to be a case of reading the source examples until you figure it out.

tools/library to do noninvasive logging

I am wondering if any tool can help do noninvasive logging for a third party assembly library. Can log4net/Postsharp do it?
Yes, there was a log4netpostsharp library but it hasn't been updated to the latest version of PostSharp so you need to do some custom aspects here most likely (very easy to do though).
An example for logging through trace and postsharp here.

Configuring log4net to Use Isolated Storage in WPF App

I'd like to use log4net's RollingAppender to write to isolated storage, but I can't figure out how to configure log4net to do so. To be clear, I'm trying to do this in an installed WPF application so I don't have some of the issues that some of the Silverlight users have already posted.
I thought my best chance was to dynamically set the file path as described in this answer, Best way to dynamically set an appender file path, but of course you don't have access to the isolated storage's file path.
Can anyone confirm whether it's possible to setup a log4net RollingAppender to use the isolated storage, and if so how?
I don't know if this will help you, but I posted an idea for creating a new Target for NLog that could write to isolated storage. I have not tested it, but it seems pretty straightforward.
Here is the link to the question where I posted my suggestion as an answer:
Logging with NLog into an Isolated Storage
Assuming it works, it would probably be pretty easy to create something similar in log4net. Of course, it would not have the same capabilities as the RollingAppender, so it might not be of much use to you, even if it does work.

How can I enable logging with Ninject?

Is there a way to get Ninject to log out what it is doing?
In particular I'd like to see when objects are being created. As I have a mix of transient and singleton objects it'd be very useful for me during debug to be able to see how many instances of each are being created so that I can fix object scopes where needed.
EDIT: N.B. I'm looking at Ninject 2 as found at http://github.com/ninject/ninject
If you look at the new web site you will see a list of extensions. 2.0 RTM is out and the extensions are being released one at a time, but you can still user them. The logging extension is here and you can track the number with a static object and provide a lambda expression to increment it in .OnActivation(...) during binding.
v1.x answer: Yes, via log adapters for a.o. log4net and NLog - see http://mhinze.com/logging-with-ninject/
[in response to comment] EDIT: v2.0 Beta answer: No:-
From Ninject 2 Reaches Beta!
Things that were in Ninject 1.x that are not in Ninject 2:
Logging infrastructure: Cut because it wasn’t really useful anyway. Ninject doesn’t generate logging messages of its own anymore, but I’m looking into alternative sources of introspection.
...

Resources