Combining NLog and log4net - log4net

My project uses both NServiceBus and RavenDB. NServiceBus uses log4Net, and RavenDB uses NLog. How should I handle logging in my project? Do I need to pick one and somehow configure one of the projects to use a different logger? Or should I just let each of them do what they want and log my own stuff in whichever I choose?
I would prefer one error log for my entire application if possible.

I would suggest that you instruct NServicebus to log to the NLog logger. To do that you need to implement a log4net.Appender.AppenderSkeleton which logs to NLog and then hook it into NService bus using
NServiceBus.Configure.With().Log4Net<YourAppender>(a => a.YourProperty = "value");
Read more about it at http://docs.particular.net/nservicebus/logging/.

Related

Integrate my custom mediator with WSO2 ESB log4j

I am writing my own custom mediator. In my custom mediator, I use log4j to log the process.. But I am facing difficulties now when deploy the custom mediator in WSO2. What I want is the log in my custom mediator will be written in the "wso2carbon.log". But unfortunately I still have no clue how to do that. Do I need to configure the log4j.properties here? or do I need to implement or extends something in my custom mediator? Thanks :)
Yes this can also be done by adding the package name along with log type needed in the log4j.properties. Doing it through the management console is also an option and you can refer http://docs.wso2.org/display/ESB470/Setting+Up+Logging to get an idea on how to do it.
I solve this using the Management Console in WSO2. In my custom mediator I use the 'info' level, and in WSO2 I think the custom mediator will have the default 'error' level. So I change the level to 'info' level, and the log is shown in the wso2 log file :)

Use NLog in Multithreading application skip the log messages

I am using NLog for my simple C#.Net application it works fine.
but when i use NLog for C#.Net multithreading application it skips the log messages
I also tried to configure NLog.config using AsyncWrapper and AutoFlushWrapper
but it does not work properly still some messages skipped.
So,Please Any Body tell me what is the best way to Configure NLog for Multithreading application without skipping any Log Messages?

Multiple log files using Log4j

I have a web application, that is build on spring webflow and jsf. Multiple users can log into my application at the same time. Now I want to use log4j to, of course, do the logging.
My question: is it possible to let log4j create different log files for every connected user?
thanks, Nikolaus
No, statically configured log4j cannot do it (unless your user set is constant and known upfront), you'd have to implement something on top of it that would set the configuration programatically.
If logback can do it, as fge says, use it, best not directly, but through slf4j.

Can I have multiple log4net configuration files?

Can I have multiple log4net configurations for the same program? Functionality similar to Spring's <import> element would be optimal. The idea here would to have multiple programs that have their own log4net configuration, as well as sharing a central log4net configuration file containing a shared error log (so that definition isn't repeated). Alternatively is this functionality possible with .NET Common Logging?
Related: log4net - configure using multiple configuration files
you can achieve this by using named repositories i think
log4net.LogManager.CreateRepository(repositoryName)
log4net.Config.XmlConfigurator.Configure(repositoryName, configFile)
then by using
LogManager.GetLogger(repositoryName,loggerName)
you can get the corresponding logger.
Not out-of-the-box. You must implement yourself the merging of different config files into a single XmlNode and pass this to log4net XmlConfiguratot.
An example is to be found here: http://www.kopf.com.br/kaplof/using-multiple-configuration-files-with-log4net

Linqpad and Log4net

I have linqpad referencing one of my own assemblies which uses log4net. When linqpad calls my assembly method I am setting my log4net logging levels to ERROR yet I see debug level messages from my assembly showing up in the linqpad results area.
Anybody know what causes this? Does Linqpad use log4net itself or have any special behavior with log4net?
LINQPad uses SharpDevelop which has a dependency on log4net, but this is kept pretty well isolated to the UI domain and shouldn't have any effect on your queries.
How are you configuring log4net? Is it programmatically or via an application config file? If it's the latter, the application config file should be named linqpad.config in order to be picked up by your queries.
I was having trouble with my configuration not being picked up. Creating a separate Linqpad.config (not editing LINQPad's own!) is the key bit of info I was missing - thanks Joe. Fantastic app by the way!

Resources