Updating log4j 1.x to 2.x

I’ve used Log4J 1.x for ages, and not even realized that the 1.x code line is not maintained any more, it seems all the activity is on 2.x as the latest maintained version of the framework.

To move from 1.x to 2.x, there’s a few changes:

If you’re using Maven for your dependencies, replace

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
</dependency>

with

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.0.2</version>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.0.2</version>
</dependency>

The API has changed from:

org.apache.log4j.Logger

and

Logger.getLogger()

 

to

org.apache.logging.log4j.Logger

and

org.apache.logging.log4j.LogManager.getLogger()

 

Sample xml config – use filename log4j2.xml instead of log4j.xml (or log4j.properties):

<?xml version=”1.0″ encoding=”UTF-8″?>
<Configuration>
<Appenders>
<Console name=”STDOUT” target=”SYSTEM_OUT”>
<PatternLayout pattern=”%C – %m%n”/>
</Console>
</Appenders>
<Loggers>
<Logger name=”example.logger.name” level=”debug”/>
<Root level=”debug”>
<AppenderRef ref=”STDOUT”/>
</Root>
</Loggers>
</Configuration>

Additional useful info here.

Adding a JMS Queue to Wildfly 8.x

The messaging subsystem in Wildfly is enabled in the standalone-full.xml config (not standalone.xml).

To add a new queue, search for <subsystem xmlns=”urn:jboss:domain:messaging:2.0″>, and then within the <hornetq-server> section, add a new <jms-destinations> if it doesn’t exist already, and define your queue name and JNDI lookup:

<jms-destinations>
    <jms-queue name="exampleQueue">
        <entry name="jms/queue/example"/>
        <entry name="java:jboss/exported/jms/queue/example"/>
    </jms-queue>
</jms-destinations>

 

Getting started with the AngularJS tutorial on Windows – issues

Here’s a quick summary of specific issues and workarounds I’ve run into so far:

  • Running ‘npm install’ and get: “Error: ENOENT, stat ‘C:\Users\[user id]\AppData\Roaming\npm”

This appears to be something removed in the node.js Windows installer. If you create the npm dir in the location above, this fixes this issue, and/or running the node.js prompt with admin privs in Windows. Covered here.

  • Error: ENOENT, no such file or directory 'c:\[some path]\package.json'

The Angular.JS tutorial steps don’t mention that you need to cd into the cloned angular-phonecat dir after you’ve grabbed it from github. Maybe this would be obvious if you’re already familiar with node.js and npm, but cd’ing into the cloned tutorial dir fixes this issue for me. Similar to this issue.

  • ‘npm start’ throws errors re binding to 0.0.0.0 and port 8000

I’m not sure if this was because something was already running on port 8000 on my Windows box, but similar to the comments on the logged comments here, if you follow the steps to edit the package.json file, you can change the bind address and/or port before starting the server. Changing from 8000 to 8080 seemed to fix it for me.

Mounting USB drives on an Ubuntu VirtualBox guest on Mac OS X host

If you’ve come across this already then this might be obvious, but in order to mount a USB external drive on an Ubuntu VirtualBox guest running on a Mac OS X host, you need to unmount the drive in Mac’s Finder first. Then using either click the USB icon in the status bar in your Ubuntu guest and you’ll see the drive un-greyed out (when it’s mounted on the Mac it appears greyed out and you can’t select it) – click it and it will mount automatically. Or you can do the same thing from the VirtualBox menu, Devices/USB.