Integrate my custom mediator with WSO2 ESB log4j - 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 :)

Related

Haskell Snap Framework configuring custom logging?

I want to implement custom logging in my Snap application so that I can pass my logs as JSON to Logstash / Kibana however I cannot figure out how to override the default logging behaviour.
Reading the code, I'm pretty sure that the logA (A for Access log) method is what is providing this logging format implicitly.
But I'm not sure how to override it. How do you override the custom logging in the snap framework? Is it impossible? Will I need to raise a PR? Cheers.
I have asked the Snap Core team if this was possible and the answer is: no, you cannot configure custom logging. Raised a feature request as a result which you can view here.

how to define multiple log4j configs with Jetty server in web.xml

Here's what I want to do:
- being able to have separated log4j.properties for each different deployment "war"
- being able to define in ant build, or web.xml, using system parameter on which log properties to use.
My project setup is Jetty with Jersey as REST API, without Spring.
I've done some research and it turns there are other Spring solutions to set in webl.xml but I'm not using spring.
I also know Jetty is using slf4j but if switching to slf4j, would I be able to do this more easily?
What would be a best way to solve this, so that in web.xml or ant build, log4j config can be customized defined?
Thanks a lot!
EDIT:
I figured that I can start another servlet with some init-param defined. Then on a separated HttpServlet implementation to set the PropertyConfigurator.configure([name of the log4j config]);
Is this adding one more servlet an ideally way of handling this?
Lots of different ways to handle this.
Since your mission is not different logging per Servlet, or per Webapp...I wouldn't solve the problem in the servlet or webapp locations but at the server level. To me, you want to log all this information to the correct place, not just all the information once the servlet has been deployed. To this end, I would enable the slf4j-api support in jetty and then look into the best way to handle that from the slf4j side of things. With that you can use whatever logging framework you want, slf4j-simple, log4j or logback..whatever you like.
Alternatively, if you really want to avoid the server side of logging, I supposed you could just use a log4j.properties file in the resources directory and then on jetty startup on the command line serve out a different resources directory. Figure out what options you want and startup with:
java -jar start.jar OPTIONS=Server,jmx,jsp,resources-[dev,qa,prod]
cheers

Combining NLog and 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/.

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.

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