Logback and Windows Event System integration - windows

Has anyone integrated with success logback and the MS Windows built-in event logger? How can it be done?
It seems to me this is an important topic but I couldn't find any useful information regarding it...

I've blogged about my implementation of logback-ntlogger: http://ykchee.blogspot.com/2012/09/logback-nt-event-log-appender.html

It doesn't seem to exist:
switch from log4j to logback
However, as is noted in that link, you can just port Log4J's NTEventLogAppender and reuse the dll's that's packaged with it.
http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/nt/NTEventLogAppender.html

Related

Websphere Liberty Support for Work Manager

I am migrating application from WebSphere to liberty. It uses WebSphere work managers.
What is the use of work manager? Is this supported in liberty. What is the alternative in liberty
I would refer to the JavaDoc for details regarding work manager, but in short
The WorkManager is the abstraction for dispatching and monitoring asynchronous work and is a factory for asynchronous beans.
WorkManager is not part of WebSphere Liberty, but you can largely recreate the functionality in Liberty by configuring a concurrencyPolicy for its managed executors. You can find more information on that here
I would also recommend looking into the WebSphere Application Server Migration Toolkit as it might help you with the migration process. You can check out an example here.
The detailed help for the migration toolkit WorkManager rule recommends the concurrency utilities and gives several links to information including the one provided above. I am wondering if you are not seeing the detailed help when you use the tool? If you are using the Eclipse tool, open the help view (Window > Show view > Help), select the analysis result, and then click on Detailed help. If you are using the binary scanner, you can view the help directly from the HTML report. When I looked at the help file, I see that one of the links is broke, and I will open an issue for this. This article gives lots of examples on how to migrate to the concurrency utilities.

OSGI Pax logging

I want to write a custom appender which will collect all the logs coming to Fuse.log in Fuse container and relay them over Scribe to a central log store. I want to add a event listener for that in the container. But I couldn't figure out how I can do that. I went through the PAX logging code. But couldn't figure out.
Any suggestions greatly appreciated.
I wrote once a blog post about this, it can be found at my blog.
Basically you just need to create your appender, the tricky part is in adding it to pax-logging in the container via a fragment bundle.
pax logging just uses log4j as the implementation. So I would write a log4j appender to do this instead. here is a library which does this already, but I've never touched it. https://code.google.com/p/scribe-log4j/

How does my spring web app capture errors that I didn't catch and log? Is this a result of apache commons?

I'm confused as to how the errors are logged without me implicitly catching them and logging out the error. All that I've done is put a log4j.xml file in my project defining appenders and now the logs catch and log everything from the frameworks.
If I say, try to query in Hibernate and the query fails, or I try to open a file that doesn't exist, or I get a null pointer exception, if the log4j.xml file defines a log file, and the error level is set correctly, then the error will be captured there?
How does my spring web app capture errors that I didn't catch and log? Is this a result of apache commons logging?
Or is this some magic that log4j knows how to deal with - catch stream to the console etc?
Any info appreciated.
From spring official documentation:
The nice thing about commons-logging is that you don't need anything else to make your application work. It has a runtime discovery algorithm that looks for other logging frameworks in well known places on the classpath and uses one that it thinks is appropriate (or you can tell it which one if you need to). If nothing else is available you get pretty nice looking logs just from the JDK (java.util.logging or JUL for short). You should find that your Spring application works and logs happily to the console out of the box in most situations, and that's important.
To make Log4j work with the default JCL dependency (commons-logging)
all you need to do is put Log4j on the classpath, and provide it with
a configuration file (log4j.properties or log4j.xml in the root of the
classpath).
Take a look for a complete explanation: http://static.springsource.org/spring/docs/3.0.x/reference/overview.html#d0e743

Integrating perf4J with maven and logback

I am having problems integrating perf4j in an existing maven application.
I tried several approaches, but none of them seemed to work, so I was wondering if anyone has some insight into how this is done.
What I want to do is use the AOP part of perf4j on some methods and log them into a different file than the one used for app logging. Thanks
You might be suffering from the same declaration order issue as mentioned in another perf4j/logback related question. In short, it is always a good idea to enable printing of logback's internal status messages by setting the debug attribute to true within the configuration element. Also do not forget that any referenced appender must be declared beforehand.

Spring JavaMailSenderImpl javax.mail.NoSuchProviderException: smtp

I have a very large project with a ton of dependancies, and am getting the following exception when trying to send mail:
javax.mail.NoSuchProviderException: smtp
I know the code works because it is part of a library that is used in other projects. Does anyone know what would cause this exception to happen? I have looked through all of the jar's and the only one containing 'javax.mail' is 'mail-1.4.4-SNAPSHOT.jar'.
Is there some file/class that registeres the 'smtp' protocol, and it could be happening somewhere else in my classpath?
It's been a while since this question has been asked but it's still worth answering :
What's happening is that your mail service is using the SMTP (usually, it is even considered as the default protocol to use)protocol to send mail. No matter what concrete class you're using as mail service (might depend on whether you're working with Java EE, Spring or something else), it ends up using classes from the javamail API. In this API, in order to establish a connection to your mail server, an instance of javax.mail.Session will be created and this object will dynamically load classes that provide support for the protocol to use.
When loading the required class, in case it is not found, the ClassNotFoundException is caught and re-threw as javax.mail.NoSuchProviderException, with a message indicating the missing protocol support.
The solution in that case is to add the smtp.jar to your classpath.
With a Maven-based project, simply add the following dependency
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>smtp</artifactId>
<version>1.4.5</version>
</dependency>
I had this issue. Putting smtp.jar in classpath solved the issue.
The way I have fixed this was to remove the mail jar from the classpath. Somewhere in the classpath there exists another instance of mail.jar, and I have yet been able to find it. If anyone else runs into this problem, additional information on trouble shooting can be found here:
http://forum.springsource.org/showthread.php?t=90737
and
http://forums.sun.com/thread.jspa?threadID=5442371
I got same problem while we upgrade jboss from 4.x to 6.x.
Here Problem is setting classpath to the more number of mail.jar files(default server will take the mail.jar from its common/lib foler if it available there).
To confirm which jar file it is using, following statement is usefull.
System.out.println(getClass().getResource("/javax/mail/Address.class"));
if it is using the another jar file which you are not expecting.. set classpath to that instead which you are using. other wise remove that jar file from the above printed location.
This can also happen when you have an incorrect version of the "mailapi.jar" file in your classpath as well.
I'd recently upgraded a project to use PayPal's soap API, and PayPal's distribution contained a mailapi.jar file, which was different than the one I'd currently had in my project, and caused my app to fail when sending mail.
So for me, I just had to revert to my old mailapi.jar and I was fine.
I had this isssue right now. The problem was two javax.mail.jar in the same classpath.

Resources