Where is the log4j XML config reference?


Notice: A non well formed numeric value encountered in /home/yeezil/javver.com/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118

Notice: A non well formed numeric value encountered in /home/yeezil/javver.com/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119

Notice: A non well formed numeric value encountered in /home/yeezil/javver.com/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118

Notice: A non well formed numeric value encountered in /home/yeezil/javver.com/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119

When it comes to logging in Java™ there is no shortage of alternatives. The one I’ve used the most is log4j by the Apache Foundation. In its basic usage it has no dependencies and you only need to add the ones you’ll use like SMTP support for mailing loggers, JSON configuration support or a JDBC connector to log to your favorite database. The newest version even allows asynchronous logging through the LMAX Distruptor interthread messaging API that promises greater throughput than concurrent queues and lock based thread synchronization.

Since the 2.x version came out, however, the documentation for the 1.x versions has become fragmented. There are dead links everywhere and the XML configuration method reference is not even half complete. A common question about the XML format is about validation. A more thorough search can land you on the source control version of the DTD. Let’s go through the details of what makes a valid log4j XML configuration file.

Continue reading

Zero padded hexadecimal numbers in Java


Notice: A non well formed numeric value encountered in /home/yeezil/javver.com/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118

Notice: A non well formed numeric value encountered in /home/yeezil/javver.com/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119

A quick recipe, converting an int or long like 65 to a string like 000041. It’s useful for converting integer RGB colors to the common #FFBBCC kind of web encoded colors.

 

:>

Java Suppressed Exceptions


Notice: A non well formed numeric value encountered in /home/yeezil/javver.com/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118

Notice: A non well formed numeric value encountered in /home/yeezil/javver.com/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119

Notice: A non well formed numeric value encountered in /home/yeezil/javver.com/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 118

Notice: A non well formed numeric value encountered in /home/yeezil/javver.com/wp-content/plugins/crayon-syntax-highlighter/crayon_formatter.class.php on line 119

Today I learned something new about Java exceptions. The always surprising try-catch statement has a concept called suppressed exceptions. The main idea is that a the whole try structure can throw an exception from more than one place:

  • The catch block
  • The finally block
  • The try-with-resources implicit close

Continue reading