Enable logging for Spring own components under Jetty

I just wanted to share how to enable logging for Spring own components when running a Web application under Jetty (using jetty-maven-plugin). I spent a lot of time trying to figure this out so if you are lost like I was, keep reading.

By default, Spring uses Jakarta Commons Logging (JCL) framework, whereas Jetty uses SLF4J. The trick is to configure Spring to use JCL-to-SLF4 bridge which will delegate all JCL logging to SLF4J. This can be accomplished by declaring the following dependencies in the POM:

<dependency>
	<groupId>org.slf4j</groupId>
	<artifactId>jcl-over-slf4j</artifactId>
	<version>${slf4j.version}</version>
	<scope>runtime</scope>		
</dependency>
<dependency>
	<groupId>org.slf4j</groupId>
	<artifactId>slf4j-log4j12</artifactId>
	<version>${slf4j.version}</version>
	<scope>runtime</scope>		
</dependency>

where ${slf4j.version} is a property that that defines the SLF4J version, i.e:

<properties>
	<slf4j.version>1.7.5</slf4j.version>
</properties>

It is very important that these SLF4J dependencies are not declared as Jetty plugin dependencies. They must be declared for the entire POM, otherwise this is not going to work.

Next, here is my Jetty plugin declaration:

<plugin>
	<groupId>org.eclipse.jetty</groupId>
	<artifactId>jetty-maven-plugin</artifactId>
	<version>9.0.4.v20130625</version>
	<configuration>
		<webApp>				
			<contextPath>/atgalaxy</contextPath>
		</webApp>				
		<connectors>
			<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
				<port>8080</port>
			</connector>
		</connectors>
	</configuration>
</plugin>

The above setup was tested with Spring 3.2.3.RELEASE, SLF4J 1.7.5 and jetty-maven-plugin 9.0.4.v20130625.

Posted in Spring | Leave a comment

Enable showing hidden files in Finder on Mac

In order to enable showing hidden files and directories in Finder, type the following commands in the terminal (tested successfully on Mac OS X 10.8 “Mountain Lion”):

defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder

To revert back to the default setting:

defaults write com.apple.finder AppleShowAllFiles FALSE
killall Finder
Posted in Mac OS X | Leave a comment

Converting a DMG file to an ISO format on Mac

The following command can be used to convert a DMG file to an ISO format (tested successfully on Mac OS X 10.8 “Mountain Lion”):

hdiutil convert <dmg-file> -format UDTO -o <iso-file>
Posted in Mac OS X | Leave a comment

Welcome to Designamus Blog!

Posted in Uncategorized | Leave a comment

Flushing DNS cache on Mac

Sometimes, it becomes necessary to flush DNS cache, i.e. after changing DNS records for a domain. This can be done with the following command (tested successfully on Mac OS X 10.7 “Lion” and 10.8 “Mountain Lion”):

sudo killall -HUP mDNSResponder
Posted in Mac OS X | Leave a comment